在回复之前请阅读,避免重复回答。我正在运行我的邮件服务器(postgres)。以下是'sudo netstat -anp|grep 5432'的输出:
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 29606/postmaster
unix 2 [ ACC ] STREAM LISTENING 1650581 29606/postmaster /var/run/postgresql/.s.PGSQL.5432
unix 2 [ ACC ] STREAM LISTENING 1650582 29606/postmaster /tmp/.s.PGSQL.5432
我能够使用本地主机连接
psql -h localhost (OR 127.0.0.1) -d <DB> -U user -W
但是,当我尝试使用TCP从其他主机连接时,通过指定
psql -h ip_add_postmaster -d <DB> -U user -W
它会抛出如下错误:
psql: could not connect to server: Connection refused Is the server running on host XXXXXX and accepting TCP/IP connections on port 5432?
这里出了什么问题?
pg_hba.conf
# 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
在postgresql.conf文件中,
listen_addresses = 'localhost, 127.0.0.1, ip_add_postmaster'
Note: ip_add_postmaster is same as my Elastic IP and not public DNS. If this information
matters.
我在这里做错了什么?机器托管在亚马逊 EC2 上,并已打开端口 5432。
listen_addresses
参数后是否重启了Postgres?根据netstat显示,它只设置为127.0.0.1。 - Daniel Vérité