PSQL: SSL error: unknown protocol

社会主义新天地 提交于 2019-12-12 14:59:17

问题


all. I have a new Ubuntu 17.04 server setup. I can access it through ssh successfully. Also, I have a postgresql database installed. It is already configured to accept remote connections through the following configurations:

pg_hba.conf

host all all 0.0.0.0/0  md5

postgresql.conf

listen_addresses = '*' 

But when I try to access the database from my computer, I get the following error:

psql -h [SERVER_IP]  -d db_production -U dbuser 
psql: SSL error: unknown protocol
expected authentication request from server, but received S

I also have a docker container running inside the server. If I access it through /bin/bash and also try to connect with the server db, I get this error:

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?

The port 5432 is opened and the firewall is disabled. Does anybody have gone through that?


回答1:


First, do you use the local server host when you're connected into the docker? The server IP, in that case, should be localhost or 127.0.0.1.

Try to use the complete DB URL:

psql postgres://dbuser:dbPass@SERVER_IP:5432/dbname?sslmode=prefer



来源:https://stackoverflow.com/questions/48216570/psql-ssl-error-unknown-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!