Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 18486  / 2 Years ago, tue, january 4, 2022, 3:19:35

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?


More From » postgresql

 Answers
5

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

[#34270] Wednesday, January 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
splenueak

Total Points: 448
Total Questions: 118
Total Answers: 110

Location: Vanuatu
Member since Mon, Oct 3, 2022
2 Years ago
;