【问题标题】:PSQL: SSL error: unknown protocolPSQL:SSL 错误:未知协议
【发布时间】:2018-06-21 08:15:15
【问题描述】:

全部。我有一个新的 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 访问它并尝试连接服务器 db,我会收到此错误:

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 端口打开,防火墙被禁用。有人经历过吗?

【问题讨论】:

    标签: postgresql ubuntu ssl psql


    【解决方案1】:

    首先,当您连接到 docker 时,您是否使用本地服务器主机?在这种情况下,服务器 IP 应该是 localhost127.0.0.1

    尝试使用完整的数据库 URL:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-11
      • 1970-01-01
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 2019-03-12
      • 2014-11-24
      • 2013-12-27
      相关资源
      最近更新 更多