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?
                        
You must have another
local ... peerline above those. The errorPeer authentication failedcomes from the server, and it's the server tha that picks the auth method.Other possibilities would be:
pg_hba.conffile if there are multiple PostgreSQL instances on the system.