postgreSQL pg_hba.conf - connection refused when using a LAN domain with node.js-postgres - allowed with pgAdmin 4

106 Views Asked by At

Attempts to connect using pgAdmin 4 are successful.

Attempts to connect using NPM package PG are refused.

ConnectErr connect EHOSTUNREACH fe80::xx:xxxx:xxxx:xxxx:5432 - Local (fe80::xxxx:xxx:xxxx:xxx%en5:54602)

Both attempts use the same client settings, addressing the PG server by its local domain name:

host: machineName.local
port: 5432
user: "userName"
password: "password"
database: "postgres"

The problem can be resolved by changing the hostname to the host's LAN IPv4. host:

host: 192.168.x.x

Wondering if the problem is that under the NPM package, the domain name gets translated to IPv6 and therefore gets refused?

I was under the impression that pg_hba.conf is configured to handle both IPv4 and IPv6:

# TYPE   DATABASE      USER   ADDRESS       METHOD
# "local" is for Unix domain socket connections only
local    all           all                  peer
# IPv4 local connections:
host     all           all    0.0.0.0/0     md5
# IPv6 local connections:
host     all           all    ::0/0         md5
# Allow replication connections from localhost, by a user with the replication privilege.
local   replication    all                  md5
host    replication    all    127.0.0.1/32  md5
host    replication    all    ::1/128       md5
0

There are 0 best solutions below