0

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

Jorge Arévalo
  • 197
  • 1
  • 11
  • 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 07 '14 at 00: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 07 '14 at 08:37

1 Answers1

1

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.

Craig Ringer
  • 11,083
  • 9
  • 40
  • 61
  • 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 08 '14 at 17:51