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 "111.111.11.111", user "postgres", database "production", SSL off]

111.111.11.111 - ip of the vpn, where PG database and node.js server should be running.

here is pg_hba.conf

host all all 222.222.222.2/24 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             127.0.0.1/32            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        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

222.222.222.2 - my local machine ip address

Answers


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 111.111.11.111 trust

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

host production nodejs-user 111.111.11.111 md5

and create the user "nodejs-user" in psql

Post Status

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

Search




Leave an answer