PG :: ConnectionBad(致命:pg_hba.conf拒绝主机“ 172.17.0.1”,用户“ XXX”,数据库“ XXX”,SSL关闭的连接):

时间:2019-03-14 12:05:33

标签: ruby-on-rails postgresql docker digital-ocean

我在postgres:9.4.5小滴上使用dockers的项目使用digitalocean图像。

以下是docker-compose.yml的{​​{1}}配置。

postgres

db: # use the preferred version of the official Postgres image # see https://hub.docker.com/_/postgres/ build: . # build with a different Dockerfile dockerfile: Dockerfile-pg # persist the database between containers by storing it in a volume volumes: - postgres:/var/lib/postgresql/data ports: - "5432:5432" environment: POSTGRES_USER: XXX 内部,我有以下配置

Dockerfile-pg

何时,我FROM postgres:9.4.5 EXPOSE 5432 并运行图像,我得到以下build

error

我已经设置了以下行以允许PG::ConnectionBad (FATAL: pg_hba.conf rejects connection for host "172.17.0.1", user "XXX", database "XXX", SSL off ): 文件中的所有连接

postgresql.conf

listen_addresses = '*' 文件中,我还设置了以下行以允许所有连接

pg_hba.conf

我还在本地系统上为host all all 0.0.0.0/0 trust 设置了相同的local环境。在我的本地计算机上一切正常。几天前configurations的服务器上,一切都工作正常。

我不知道为什么它尝试与此IP digitalocean连接。我为172.17.0.1的{​​{1}}设置了HOST_IP

我不知道为什么得到这个postgres。我尝试了所有修复方法。

请帮助我!

2 个答案:

答案 0 :(得分:0)

检查您的pg_hba.conf文件。 您可能有尚未添加的选项,例如

host all pgdbadm 0.0.0.0/0 md5

此pgdbadm以加密采矿黑客创建的帐户而闻名。

答案 1 :(得分:0)

向您的datasourse.url添加?ssl = true&sslmode = require 。例如

url: ${db.url:jdbc:postgresql://${db.host:localhost}:${db.port:5432}/${db.name:my_db}}?ssl=true&sslmode=require
相关问题