Last Updated: February 25, 2016
· nosolopau

Avoiding "Peer authentication failed" error when connecting to a local database with psql

Two options here:

A. Connect to the database with the user postgres:

$ sudo -u postgres psql

B. Specify the host (-h option) to force a TCP connection (TCP connections allow password authentication):

$ psql database -U user -h localhost

Enjoy :)