Say you're seeing this message:
FATAL: Ident authentication failed for user "..."
What are the causes of this error message?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
It means that Postgres is trying to authenticate a user using the Ident protocol, and can't. Ident auth automatically matches Unix usernames with Postgres usernames. It works like this:
/etc/postgres-something/main) defines 'Ident' as the protocol to connect to database
dbfor users connecting from certain hosts
Possible causes and solutions:
There is no Ident server running on the machine you're trying to connect from. Test this by trying to connect to it on port 113. If that fails, install an Ident server (eg,
sudo apt-get install oidentd).
There's an Ident server, but there's no database role matching the name you're trying to connect with ('foo' in the above example). So create it by connecting somehow to the database with superuser rights and do
CREATE ROLE foo. Alternatively add an entry to
/var/lib/pgsql/12/data or wherever).
Maybe the shell username doesn't match the database role. You may be able to test this by connecting to the Ident server while a connection is going on, and passing the right port numbers.
Maybe you actually want to connect with a password, not Ident. Edit the
pg_hba.conf file appropriately. For example, change:
host all all 127.0.0.1/32 ident
host all all 127.0.0.1/32 md5
Be sure to restart Postgres after updating the
pg_hba.conf file. You do that by issuing the following command:
sudo service postgresql-12 restart
For Centos 7, Change pg_hba.conf to below:
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: #host all all 127.0.0.1/32 ident host all all 127.0.0.1/32 md5 # IPv6 local connections: #host all all ::1/128 ident host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. #local replication all peer #host replication all 127.0.0.1/32 ident #host replication all ::1/128 ident
If you have not tried this already, review your pg_hba.conf file. It will be named something like /var/lib/pgsql/9.3/data/pg_hba.conf (Fedora 20); you may have to use 'find / -name pg_hba.conf' to locate it.
At the bottom of the file, change the 'METHOD' values to 'trust' for local testing (see postgres docs for full information). Reboot the machine to ensure everything is started clean and the new params are read.
Hopefully this will cure your woes. It solved my problems on Fedora 20 with PostgreSQL 9.3.