I'm trying to log into my DB and am getting this error...

root@---:~# psql -U user database
psql: FATAL:  Peer authentication failed for user "user"

What does this mean? I'm pretty sure I can fix it by putting peer into my pg_hba.conf but I'm not sure if I should so so...

4 Answers 4


It means that the system attempted peer authentication (…obtaining the client's operating system user name from the kernel and using it as the allowed database user name (with optional user name mapping). This method is only supported on local connections.), and it failed.

Is your pg_hba.conf configured for peer authentication for local connections?
If so you may need to change that to a more appropriate auth method such as md5 or trust(not recommended).
Refer to the Postgres Manual for more information.


You should explicitly specify the --host parameter and then Password authentication will be used instead of Peer.


psql -u someuser -h

This is a suggestion : Use only md5 or trust(not recommended) to access your DB. Having Peer in my pg_hba.conf messed up my understanding of Postgresql. I am still learning but having md5 in that file makes authentication predictable and understandable.


first do a sudo su databaseuser; then run the psql command wihtout the -U switch

  • 1
    This would need a lot more explanation on what this is supposed to do.
    – Sven
    Jul 19, 2017 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.