Home Ask Login Register

Developers Planet

Your answer is one click away!

stkvtflw February 2016

Postgres debian server deploy error: no pg_hba.conf entry for host

I've installed Postgres on vpn (Debian 7.0). If i'm running node.js server locally and connecting it to remote PG, it works absolutely perfect.
But when i'm the repo to vpn and trying to run node.js server there, i'm receiving this error:

error fetching client from pool { [error: no pg_hba.conf entry for host "", user "postgres", database "production", SSL off] - ip of the vpn, where PG database and node.js server should be running.

here is pg_hba.conf

host all all trust
# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all               md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres            md5
#host    replication     postgres        ::1/128                 md5 - my local machine ip address


colttt February 2016

you must config you node.js to use localhost (unix-socket), if you use the IP-address you must add it tou you pg_hab.conf like:

host production postgres trust

BUT I would recommend to use a different user to connect to you database for security reasons, for example:

host production nodejs-user md5

and create the user "nodejs-user" in psql

Post Status

Asked in February 2016
Viewed 2,716 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life