HostOnNet Blog

PostgreSQL FATAL: Peer authentication failed for user “USER_NAME”

Looking for Linux Server Admin or WordPress Expert? We can help.

postgresql

On running a Ruby On Rails Application (anyone else use PostgreSQL ?), i get following error

FATAL:  Peer authentication failed for user "DB_NAME"

This is fixed by editing file pg_hba.conf

vi /etc/postgresql/9.5/main/pg_hba.conf

9.5 is version of postgresql. So it will be different on your server.

On CentOS Server, the file location is

vi /var/lib/pgsql/data/pg_hba.conf

Find

# "local" is for Unix domain socket connections only
local   all             all                                     peer

Replace with

# "local" is for Unix domain socket connections only
local   all             all                                     md5

Restart PostgreSQL

root@s1:~# service postgresql stop
 * Stopping PostgreSQL 9.3 database server [ OK ] 
root@s1:~# service postgresql start
 * Starting PostgreSQL 9.3 database server [ OK ] 
root@s1:~#

Back to PostgreSQL

Posted in Windows

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.