how to fix no pg_hba.conf entry for host "::1"

Viewed 3041

I'm standing up a new application and having some issues with host based authentication. I know there are other posts out there (espec this one) but nothing I try seems to work.

My error:

no pg_hba.conf entry for host "::1", user "root", database "db_name_here", SSL off

My pg_hba.conf file looks like:

# TYPE  DATABASE    USER  ADDRESS METHOD
local   all         all           peer map=usermap
local   replication all           peer map=usermap
hostssl all         all   all     md5
host    replication all   all     md5

I have a note to myself from the past where I said the following worked:

host   db_name_here   root  ::1  trust

But it doesn't.

I've even tried:

all     all     all     all     trust

even that didn't work, same error.

I've read the postgresql docs, and while the helped explain what was going on, (and made me try hostnossl, to no avail) I'm still getting the same error.

Do you see my mistake?

2 Answers

Have you tried allow IPv6 localhost seperately like this

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             ::1/128                 trust

Your pg_hba.conf entry is missing the netmask; a plain IP address is a syntax error. This one should work:

host   db_name_here   root  ::1/128  trust

Make sure you reload the database with

pg_ctl -D /path/to/datadir reload

and check the log file for errors (that is important, as a syntactically wrong file won't be loaded).

The alternative is to enable SSL on the server side and use it for the local connection.

The fastest way to connect would be via Unix sockets (if you are not on Windows or use the JDBC driver), perhaps that is the best thing to do.

Related