11

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

11

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.

2
6

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

Example:

psql -u someuser -h 127.0.0.1
0

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.

-1

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .