"服务器没有收听"连接到我的远程数据库

时间:2018-05-11 18:58:50

标签: postgresql nginx

我在远程服务器上有一个Postgres数据库。我在pgAdmin中填写此信息。

Name: my-server
Host: SERVER.IP.ADDRESS.HERE
Port: 5432
Maintenance DB: postgres
Username: django
password: mysecretpassword

当我点击" OK"我收到了这个错误窗口。

Server doesn't listen

The server doesn't accept connections: the connection library reports 
could not connect to server: Connection refused Is the server running on host "SERVER.IP.ADDRESS.HERE" and accepting TCP/IP connections on port 5432? 

如何在运行Ubuntu 14.04的远程服务器上查看Postgres运行的端口?为什么我会收到此错误?

更新

SELECT * FROM pg_settings WHERE name = 'port';。港口肯定是5432。

nano /etc/postgresql/9.4/main/postgresql.conf。取消注释listen_addresses所以看起来像这样:

listen_addresses = 'localhost','*' 

nginx restart,再次尝试连接。同样的错误。

2 个答案:

答案 0 :(得分:1)

您可以像这样检查端口:SELECT * FROM pg_settings WHERE name = 'port';

答案 1 :(得分:0)

正在运行sudo /etc/init.d/postgresql restart摆脱了错误。