I want to connect to my local installation of PostgreSQL 9.1 using my machine user (who is vagrant). So, after reading PostgreSQL documentation, I thought I just needed to:

  1. Add username map in pg_ident.conf:

    vp vagrant postgres

  2. Using the map in pg_hba.conf

    local all all peer map=vp

But I'm getting the error

sql: FATAL:  Peer authentication failed for user "vagrant"

If I try to connect to my server using psql.

I guess I'm misunderstanding the PostgreSQL manual. But, how could I get what I need? (locally connect with the user vagrant like if it was the postgres user)

Many thanks in advance

  • That looks fine to me as written; where's that line in pg_hba.conf? Is there a prior line for local that might match the database/user combo before this one does? Did you reload/restart PostgreSQL? – Craig Ringer Aug 7 '14 at 0:53
  • Yes, there is a previous line in pg_hba.conf like: local postgres peer (meaning 'use peer authentication for local connection of postgres user, and I didn't add map) – Jorge Arévalo Aug 7 '14 at 8:37

Per comments, there was a prior pg_hba.conf line that also matched the criteria, and didn't have a map entry.

It was being matched first, so the one with the map wasn't reached.

| improve this answer | |
  • You're right! I've added the map=vp to the first entry of pg_hba.conf (local all postgres peer map=vp), and it works now. The user 'vagrant' is mapped with 'postgres', as desired. Thanks! – Jorge Arévalo Aug 8 '14 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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