PostgresSQL deploy:migrate issue while deploying with Capistrano Rails

March 13, 2017 878 views
PostgreSQL Ruby on Rails Ubuntu 16.04

Hello !
I'm trying to deploy a rails 5 app with ubuntu 16.04 etc... On cap production deploy I get the following error on deploy:migrate

INFO [deploy:migrate] Run rake db:migrate
DEBUG [15816e11] Running if test ! -d /home/deploy/app/releases/20170313091718; then echo "Directory does not exist '/home/deploy/app/releases/20170313091718'" 1>&2; false; fi as deploy@
DEBUG [15816e11] Command: if test ! -d /home/deploy/app/releases/20170313091718; then echo "Directory does not exist '/home/deploy/app/releases/20170313091718'" 1>&2; false; fi
DEBUG [15816e11] Finished in 0.306 seconds with exit status 0 (successful).
INFO [64a72276] Running ~/.rvm/bin/rvm default do bundle exec rake db:migrate as deploy@
DEBUG [64a72276] Command: cd /home/deploy/app/releases/20170313091718 && ( export RAILSENV="production" ; ~/.rvm/bin/rvm default do bundle exec rake db:migrate )
DEBUG [64a72276] rake aborted!
DEBUG [64a72276] PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "" and accepting
TCP/IP connections on port 5432?
DEBUG [64a72276] /home/deploy/app/shared/bundle/ruby/2.4.0/gems/activerecord-5.0.2/lib/active
record/connectionadapters/postgresqladapter.rb:671:in `initialize'

Do you have any pointers? to make it work can't seem to find similar issue on deployment server

note i tried this it didn't work: https://www.digitalocean.co...

All input welcomed thanks!

2 Answers
hansen March 13, 2017
Accepted Answer

You've configured Rails or the apps to connect to the database via, which is failing.
So are you running PostgreSQL locally?
If yes (running locally), then change the configuration host to or a socket.
If no (running externally), then there's probably a firewall blocking on the database server.

Thanks I had typed in 138 etc instead of 127... in the database.yml :/

Have another answer? Share your knowledge.