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

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

我已经在 vpn (Debian 7.0) 上安装了 Postgres。如果我在本地 运行ning node.js 服务器并将其连接到远程 PG,它绝对完美。
但是当我是 vpn 的 repo 并尝试 运行 node.js 服务器时,我收到此错误:

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 - vpn 的 ip,其中 PG 数据库和 node.js 服务器应该是 运行ning.

这里是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 - 我的本机ip地址

您必须配置您 node.js 以使用 localhost (unix-socket),如果您使用 IP 地址,您必须将其添加给您 pg_hab.conf 喜欢:

host production postgres 111.111.11.111 trust

但出于安全原因,我建议使用不同的用户连接到您的数据库,例如:

host production nodejs-user 111.111.11.111 md5

并在 psql

中创建用户 "nodejs-user"