Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have the following scenario:

saji@geeklap:~$ psql -U postgres
psql: FATAL:  Ident authentication failed for user "postgres"

saji@geeklap:~$ psql -h localhost -U postgres
Password for user postgres: 
psql (8.4.14)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

postgres=# 

I'm trying to log into the postgresql server installed in my system as user postgres. I'm able to login only if I specify -h localhost. Whereas psql documentation says that:

If you omit the host name, psql will connect via a Unix-domain socket to a server on the local host, or via TCP/IP to localhost on machines that don't have Unix-domain sockets.

Ref: http://www.postgresql.org/docs/current/static/app-psql.html#R2-APP-PSQL-CON

Why am I unable to login without specifying the host, is there some configuration file that needs any change for things to occur as told in the psql documentation?

share|improve this question

migrated from stackoverflow.com Nov 16 '12 at 12:17

This question came from our site for professional and enthusiast programmers.

    
Create a .psqlrc that specifies the defaults - or just edit pg_hba.conf to use md5 authentication for local (unix socket) connections. See the documentation for pg_hba.conf and psql. –  Craig Ringer Nov 15 '12 at 22:44
add comment

1 Answer 1

up vote 2 down vote accepted

In fact, it works as documented.

When the host name is omitted, psql connects to the Unix-domain socket whose path is compiled in. That part works in your case, otherwise it would output a different error message than what the question shows.

The error message in the question:

psql: FATAL:  Ident authentication failed for user "postgres"

relates to the fact that only the Unix user postgres has the permission to connect as the database user postgres when using a Unix-domain socket. This is configured in the pg_hba.conf file.

what you should typically do in Ubuntu when you're logged in as a normal user, but you're the administrator of the system:

$ sudo -u postgres psql
share|improve this answer
1  
Thanks.. Please change sudo -u postgresql psql to sudo -u postgres psql. I tried to edit. But couldn't, as the edit has only <6 characters. –  saji89 Nov 16 '12 at 4:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.