Database connection error on Rails application with postgresql database

Posted July 4, 2015 10.7k views
Ruby on RailsUbuntuPostgreSQLDigitalOcean 1-Click Apps Marketplace

Good day! Could You help me with issue after installing RoR image with postgresql - generate model and after it make migration: rake db:migrate RAILSENV=production. Get a mistake - “PG:ConnectionBad: fesendauth: no password supplied”. What can I do? (export APPDATABASEPASSWORD=**** helps only if there is no restart).

1 comment
  • export APPDATABASEPASSWORD=<production_database_password>

    <production_database_password> can be found when you first ssh into your digital ocean account

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.

Submit an Answer
3 answers


I was having the same error, and for me the environment variables wan’t set. It was just a matter of executing “. /etc/default/unicorn” as seem here to properly setup the variables.

After that all started working again.

Can you verify if the database works outside of the Rails environment?

What happens when you run these commands in console/terminal?

Run a login test:

psql -U postgres

Run a port test:

netstat -nlp | grep 5432

  • psql -U postgres **
    ==> psql: FATAL: Peer authentication failed for user “postgres”
    **netstat -nlp | grep 5432

    ==> tcp 0 0* LISTEN
    unix 2 [ ACC ] STREAM LISTENING 32295 4917/postgres
    P.S. Changed authentication to md5 in pghba.conf. Tried to log in from shell “psql -U rails” - everything is Ok, but migration still doesnt work with old issue “fesendauth....”