Database connection error on Rails application with postgresql database

July 4, 2015 4.2k 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

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.

DigitalOcean's Ruby on Rails One-click application provides a convenient way to get your Rails application running on an Ubuntu server. With Nginx, Unicorn, and Postgres all pre-installed, the One-click is a great base for hosting your app. In this tutorial, we'll show you how to create a Droplet, where to find the usernames and passwords, and how to restart the key services on the Droplet.

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.