PostgreSQL Database: PG::ConnectionBad: FATAL: Peer authentication failed for user

If, when working on a Linux machine of the Ubuntu flavor and setting up a PostgreSQL 9.3 database, you run into the error ‘PG::ConnectionBad: FATAL: Peer authentication failed for user’ when trying to connect to a database from a web application (Rails, PHP, Node, etc.), you are more than likely running into local socket connection permissions within PostgreSQL. The most common fix for this error in a development or staging environment is to loosen the local permissions up a bit.

How To:
1. locate the file ‘/etc/postgresql/9.3/main/pg_hba.conf’ and open it using sudo (sudo nano /etc/postgresql/9.3/main/pg_hba.conf)
2. scroll down through the file (almost to the bottom) until you find the section that starts with ‘# Database administrative login by Unix domain socket
3. directly below that you will find ‘local all all peer’ change it to ‘local all all trust’
4. save and close the file
5. restart the PostgreSQL server (sudo service postgresql restart)

Mint 14/PostgreSQL: Peer authentication failed for user "someuser"

After you have installed PostgreSQL 9.1 on your Linux Mint 12/13/14, created a user login, a database with that user as the owner and try to connect to that database using that user, you may run into the following error:
Password for user someuser:
: FATAL:  Peer authentication failed for user “someuser”

If this is the case, you need to open up this file /etc/postgresql/9.1/main/pg_hba.conf in a text editor (with root privileges) and change this line:

local   all             all                                     peer

to this:

local   all             all                                     md5

After changing and saving the file, restart the PostgreSQL server:

sudo service postgresql restart
You should not have no issue connecting to your databases using the associated user.