psql不能连接到PostgreSQL服务器(postmaster)在IP和端口5432?
发布时间:2020-12-13 16:25:56 所属栏目:百科 来源:网络整理
导读:请在回覆之前阅读,因为它可能发生重复.我正在运行我的postmaster(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/postmaste
请在回覆之前阅读,因为它可能发生重复.我正在运行我的postmaster(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 我可以使用localhost连接 psql -h localhost (OR 127.0.0.1) -d <DB> -U user -W 但是当我尝试使用tcp从其他主机连接时,通过指定 psql -h ip_add_postmaster -d <DB> -U user -W 它抛出:
这里有什么问题? 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. 我在这里做错了什么?机器托管在Amazon EC2上,并打开端口5432.
当你的netstat输出显示为127.0.0.1:5432,这是localhost.这只能从localhost连接;)
在你的配置中设置listen_addresses =’*’,它将工作. [编辑] >亚马逊防火墙是否阻止任何东西? 但首先要确保收听地址是正确的,你的netstat输出显示它不会这样工作. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |