Is the server running on host "host_name" (XX.XX.XX.XX)
and accepting TCP/IP connections on port 5432?
尝试设置数据库服务器时出现典型错误消息。但我无法解决它。
我的django数据库设置:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'db_name',
'USER': 'db_user',
'PASSWORD': 'db_pwd',
'HOST': 'host_name',
'PORT': '5432',
}
}
我添加到pg_hba.conf
host all all 0.0.0.0/0 md5
host all all ::/0 md5
我替换为postgresql.conf
:
listen_addresses = 'localhost'
至listen_addresses = '*'
并且postgresql重启:
/etc/init.d/postgresql stop
/etc/init.d/postgresql start
但仍然得到同样的错误。有趣的是:
我可以从外面ping XX.XX.XX.XX
并且它有效。但我不能telnet:
telnet XX.XX.XX.XX
Trying XX.XX.XX.XX...
telnet: connect to address XX.XX.XX.XX: Connection refused
telnet: Unable to connect to remote host
如果我从外面telnet端口22,它可以工作:
telnet XX.XX.XX.XX 22
Trying XX.XX.XX.XX...
Connected to server_name.
Escape character is '^]'.
SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u3
如果我从数据库服务器内部telnet端口5432,我得到这个:
telnet XX.XX.XX.XX 5432
Trying XX.XX.XX.XX...
Connected to XX.XX.XX.XX.
Escape character is '^]'.
外面的同一个港口:
telnet XX.XX.XX.XX 5432
Trying XX.XX.XX.XX...
telnet: connect to address XX.XX.XX.XX: Connection refused
telnet: Unable to connect to remote host
来自内部的nmap:
Host is up (0.000020s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
5432/tcp open postgresql
来自外部的nmap:
Starting Nmap 7.60 ( https://nmap.org ) at 2018-01-24 07:01 CET
并且没有回应。
这听起来像防火墙问题,但我不知道在哪里寻找。我做错了什么,可能是什么问题?
任何帮助表示赞赏。
btw:我可以在服务器内登录postgresql,它可以工作:
psql -h host_name -U user_name -d db_name
psql (9.4.15)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
db_name =>
答案 0 :(得分:0)
问题是防火墙阻止这些端口。我试图与托管公司沟通,但最后我不得不将服务器更改为其他托管公司,并且它使用了确切的设置