建立 PostgreSQL 远程连接失败
我尝试过其他答案中提到的方法,但发现都失败了。我对配置所做的如下。
- 修改了“pg_hba.conf”文件
# IPv4 local connections:
#host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
- 修改了“postgresql.conf”文件
# - Connection Settings -
listen_addresses = '*'
- 重新启动服务器
sudo service postgresql restart
但仍然无法建立远程连接。
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "xxx.xxx.xxx.xxx" and accepting
TCP/IP connections on port 5432?
通过以下命令打开端口 5432:
xx@xx:~$ netstat -nlt|grep :5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
我可以 ping 通 PostgreSQL 所在的 IP 地址。
I have tried the method mentioned on the other answers, but only to find they all failed. What I did to the configuration are below.
- Modified the "pg_hba.conf" file
# IPv4 local connections:
#host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
- Modified the "postgresql.conf" file
# - Connection Settings -
listen_addresses = '*'
- Restart the server
sudo service postgresql restart
But I still failed to build the remote connection.
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "xxx.xxx.xxx.xxx" and accepting
TCP/IP connections on port 5432?
The port 5432 was open by the following command:
xx@xx:~$ netstat -nlt|grep :5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
And I could ping the IP address where the PostgreSQL was.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论