即使postgres中的listen_addresses ='*',远程登录也不起作用 [英] Even with listen_addresses ='*' in postgres, remote login is not working
问题描述
我想使用远程主机登录到postgres。
I want to login to postgres using remote host.
我已将postgresql.conf文件配置为listen_addresses ='*'
I have configured the postgresql.conf file with listen_addresses ='*'
我已使用
host all all 0.0.0.0/0 md5
但是我仍然无法登录,但看到以下错误
But still I am unable to login and I see the following error
-bash-4.2$ psql -d sbtest -U postgres -W -h 10.54.48.59
Password:
psql: could not connect to server: Connection refused
Is the server running on host "10.54.48.59" and accepting
TCP/IP connections on port 5432?
-bash-4.2$
上面没有防火墙
,并且端口5432已打开
There is not firewall on it and the port 5432 is open
推荐答案
我今天也遇到了同样的问题,我正在按照此处。花了几个小时后,我发现了两个愚蠢的错误。
I faced the same issue today and I was following the steps from here. after spending few hours, I found my two silly mistakes. In case it help the other..
1)您将看到两个键 listen_address
和 postgresql.conf
文件中> listen_addresses 。每次查看时,我都在修改错误的密钥 listen_address =‘*’
,然后继续重新启动服务,但是我没有工作。正确的关键字是复数
1) You will see two keys listen_address
and listen_addresses
in postgresql.conf
file. everytime I look at it, I was modifying the wrong key listen_address = '*'
and then keep on restarting service, but i did not worked. the correct key to look for is plural one
listen_addresses = '*'
2)在 pg_hba.conf
文件中,而不是添加新行,我们需要 modify 修改现有行,该行指向 127.0.0.1
地址。我的错误是,我在添加另一行
2) In pg_hba.conf
file, instead of adding new row, we need to modify the existing row which is pointing to 127.0.0.1
address. my mistake was, I was adding another row with
host all all 0.0.0.0/0 md5
检查端口是否打开全部或仅对localhost使用
Check if the port is open for all or only for localhost using
sudo netstat -ntlp | grep LISTEN
这篇关于即使postgres中的listen_addresses ='*',远程登录也不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!