Postgres not accepting connection if I say -h localhost
but it works if I say -h 127.0.0.1
[root@5d9ca0effd7f opensips]# psql -U postgre
Postgres will potentially use IPv6 when specifying -h localhost
which given the above pg_hba.conf
specifies ident
, a password prompt will be returned.
However when -h 127.0.0.1
is specified, it forces Postgres to use IPv4, which is set to trust
in above config and allows access without password.
Thus the answer is to modify the IPv6 host line in pg_hba.conf
to use trust
:
# IPv6 local connections:
host all all ::1/128 trust
Remembering to restart the Postgres service after making config changes.