PSQL:SSL错误:未知协议

4

大家好。我有一个新的Ubuntu 17.04服务器设置,可以通过ssh成功访问。此外,我已经安装了postgresql数据库,并已配置为接受远程连接,配置如下:

pg_hba.conf

host all all 0.0.0.0/0  md5

postgresql.conf

listen_addresses = '*' 

但是当我尝试从我的电脑访问数据库时,会出现以下错误:
psql -h [SERVER_IP]  -d db_production -U dbuser 
psql: SSL error: unknown protocol
expected authentication request from server, but received S

我还有一个在服务器内运行的Docker容器。如果我通过/bin/bash访问它并尝试连接服务器数据库,我会收到以下错误信息:

psql -h [SERVER_IP]  -d db_production -U dbuser
psql: could not connect to server: Connection refused
    Is the server running on host "[SERVER_IP]" and accepting
    TCP/IP connections on port 5432?

端口5432已打开,防火墙已禁用。有人经历过这种情况吗?
1个回答

0
首先,当您连接到Docker时,您是否使用本地服务器主机?在这种情况下,服务器IP应该是localhost127.0.0.1
尝试使用完整的DB URL: psql postgres://dbuser:dbPass@SERVER_IP:5432/dbname?sslmode=prefer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接