PostgreSQL: MD5 Authentication in pg_hba.conf gives me FATAL: Peer authentication failed for user "postgres"

2.7k views Asked by At

I'm running Ubuntu 14.04 and installed PostgreSQL 9.3. Edited /etc/postgresql/9.3/main/pg_hba.conf as:

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

I restarted the server and now I'd like to login into postgres as postgres:

victor@workstation:~$ psql -U postgres
psql: FATAL:  Peer authentication failed for user "postgres"

Shouldn't postgres prompt for my password, as I've set its authentication method to MD5 ?

I understand that if I add -h localhost it will work.

Does not adding this flag causes psql to use peer-authentication?

2

There are 2 answers

1
Craig Ringer On BEST ANSWER

You must have another local ... peer line above those. The error Peer authentication failed comes from the server, and it's the server tha that picks the auth method.

Other possibilities would be:

  • Didn't actually restart the server
  • Edited the wrong pg_hba.conf file if there are multiple PostgreSQL instances on the system.
0
Eswar On

1) Open -> /etc/phppgadmin -> config.inc.php from your Terminal.

2) Find Below Line and Change it to False.

$conf['extra_login_security'] = true; to $conf['extra_login_security'] = false;

3) After changing Restart your Server.it will resolve your issue.

/etc/init.d/httpd restart