Error Message: “Peer authentication failed for user ‘username’” when connecting to a PostgreSQL database from a Django application
Error Message:
psycopg2.OperationalError: FATAL: Peer authentication failed for user “username”
I was setting up a friend’s project on my Ubuntu 12.04 laptop last night and ran into this database connection problem when I tried to ran his Django application.
There are actually 2 solutions to this problem:
Solution 1:
In your settings.py file, in the database settings, set the ‘HOST’ to ‘localhost’ instead of an empty string.
Solution 2:
Modify the /etc/postgresql/9.1/main/pg_hba.conf file and change …