Database connection error on Rails application with postgresql database

July 4, 2015 2.4k views
One-Click Install Apps PostgreSQL Ruby on Rails Ubuntu

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

2 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.

DigitalOcean's Ruby on Rails One-Click application provides a convenient way to get your Rails app up and running quickly. With Nginx, Unicorn, and Postgres all pre-installed, the One-Click is a great base for hosting your app. This tutorial will give you all the details you need to get your project off the ground.

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...."

Have another answer? Share your knowledge.