PostgresSQL deploy:migrate issue while deploying with Capistrano Rails

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 RAILS_ENV=“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/connection_adapters/postgresql_adapter.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:

All input welcomed thanks! Thanks

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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 :/

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel