error: no pg_hba.conf entry for host code example

Example 1: no pg_hba.conf entry for host user database ssl off

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.

Example 2: no pg_hba.conf entry for host SSL off

listen_addresses = '*'
/etc/init.d/postgresql restart

Example 3: no pg_hba.conf entry for host heroku

"FATAL: no pg_hba.conf entry for host" errors indicate that there was a failed authentication attempt to the database, so the connection couldn't be established. This can happen because of different reasons:

The authentication failed because the user/password credentials were invalid: ((user "xxxx", database "yyyy")). This could happen if you're trying to connect to the database using wrong or revoked credentials. (See also: Why am I seeing connection errors for my Heroku Postgres database from an unexpected IP address?).

The authentication failed because the connection didn't use SSL encryption: (SSL off). All Heroku Postgres production databases require using SSL connections to ensure that communications between applications and the database remain secure. If your client is not using SSL to connect to your database, you would see these errors even if you're using the right credentials to connect to it.

Example 4: vagrant no pg_hba.conf entry for host

host  all  all 0.0.0.0/0 md5

Tags:

Misc Example