connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host
Add or edit the following line in your postgresql.conf
:
listen_addresses = '*'
Add the following line as the first line of pg_hba.conf
. It allows access to all databases for all users with an encrypted password:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
host all all 0.0.0.0/0 md5
Restart Postgresql after adding this with service postgresql restart
or the equivalent command for your setup.
This solution works for IPv4 / IPv6
nano /var/lib/pgsql/data/pg_hba.conf
add at final
host all all ::1/128 md5
host all postgres 127.0.0.1/32 md5
and then restart postgresql service
/etc/init.d/postgresql restart
The way I solved this was:
Added the line as below in pg_hba.conf
:
hostnossl all all 0.0.0.0/0 trust
and this was modified in postgresql.conf
, as shown:
listen_addresses = '*'
I had this instance running on a Centos 7.3 and Postgres 9.5 in a VM in Azure, given this was a POC (proof of concept) you won't want to connect without SSL in your actual prod environment.
To connect to the instance I was using pgAdmin 4 on macOS Sierra.