我在远程服务器上有一个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
,再次尝试连接。同样的错误。
答案 0 :(得分:1)
您可以像这样检查端口:SELECT * FROM pg_settings WHERE name = 'port';
答案 1 :(得分:0)
正在运行sudo /etc/init.d/postgresql restart
摆脱了错误。