FATAL: Ident authentication failed for user [username] Error – PostgreSQL

If you’re getting a FATAL: Ident authentication failed for user [username] Error when attempting to connect to postgres as a specific user, chances are you need to change some security settings.

Postgresql, by default, only allows you to connect to postgres if the postgres username is the same as your username on the operating system. In other words, if you’re logged in to your computer as frank, you can, in general, only connect to the postgres server as the frank user.

To allow connection as any existing postgres user, the following lines need to be added to the pg_hba.conf:

local all all trust
host all all 127.0.0.1/32 trust

Note that if there is a line in the file like:

local all all ident sameuser

Then the extra lines you add need to be above this line.

If you don’t know where to find this file, on ubuntu it can be found at:

/etc/postgresql/[version]/main/pg_hba.conf

This path should be similar on other linux distributions.

Leave a Reply

Your email address will not be published.