3

In /var/lib/pgsql/9.1/data/pg_hba.conf, I have the following:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             127.0.0.1/32            trust

But when I execute

su -c "psql -d postgres" - postgres

it asks me for a password. My expectation is that users should not be prompted for a password.

Steve
  • 200
  • 2
  • 4
  • 13
  • 2
    If you don't specify a host through [`-h`/`--host`](http://www.postgresql.org/docs/current/static/app-psql.html) then `psql` will (try to) connect through Unix-domain socket. Which is type `local` in the [`pg_hba.conf`](http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html). – Milen A. Radev May 19 '12 at 20:29
  • If you are on MacOS local socket connections will be made via IPv6 by default – ctpenrose Jun 21 '16 at 19:49

2 Answers2

1

There were other settings in there for local and IPv6 connections which were not trust. I made them all trust and it works now. So it looks like psql doesn't connect via IPv4.

Steve
  • 200
  • 2
  • 4
  • 13
0

The address of the record with the trust field in the pg_hba.conf file needs to be ::1/128, presumably because the PostgreSQL server running on your local machine is using an address in that range.

bit
  • 101