0

I can't connect to my local Postgresql database on my Linux Fedora setup using an account I've created (alex). I've tried lots of different things including changing the 'method' to md5 and such. Here's a copy of my pg_hba.conf file:

local   all             all                                     peer
local   project         alex                                    peer
host    all             all             127.0.0.1/32            ident
host    all             all             ::1/128                 ident

The user 'alex' has login permissions and replication permissions along with a password (encrypted).

psql -U alex -d project -h 127.0.0.1
psql: FATAL:  Ident authentication failed for user "alex"

Forcing password input with the '-W' switch causes this to happen:

psql -U alex -d project -h 127.0.0.1 -W
Password for user alex: 
psql: FATAL:  Ident authentication failed for user "alex"

2 Answers 2

1

You're using TCP/IP (-h 127.0.0.1 or -h localhost) so it's using the host lines. The local lines are for unix sockets and do not apply to TCP/IP.

So it's choosing ident authentication, which expects that the connecting user have the same unix user name as the PostgreSQL user they're connecting to. It's also not well supported in modern operating systems. (I personally think that defaulting to ident authentication is effectively a bug).

I suggest using md5 password authentication instead of ident. Remember to reload the configuration to make change take effect.

Alternately, omit the -h 127.0.0.1 to use peer authentication over a unix socket, if your current unix user name matches the name of the PostgreSQL user you wish to connect as.

Sign up to request clarification or add additional context in comments.

Comments

0

Fixed it, I guess the higher that the entry is then the higher the priority it is inside the pg_hpa.conf file. I removed the top peer entry, and problem solved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.