Postgresql – what does peer authentication mean for postgresql

postgresql

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…

Best Answer

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.