【问题标题】:How to connect to gcloud postgres db from a container inside cloud run如何从云运行中的容器连接到 gcloud postgres db
【发布时间】:2020-11-29 18:18:58
【问题描述】:

我的云运行中有一个容器,它期望接收DATABASE_URL 变量。 我想连接到我现有的 GCP postgres db,但我无法让它工作。 我已经在我的数据库实例上定义了一个私有 IP 并尝试通过这个 url 字符串进行连接

postgres://<db-user-name>:<my-password>@<my-ip>/<my-db-name>

在日志中我可以看到它只是库存:

level=info msg="Connecting with postgres://<username>:<password>@<db-ip>/<dbname>"

几分钟,然后它说:

level=info msg="Unable to connect to database" error="Could not Connect to SQL: dial tcp <ip>:5432: connect: connection timed out"

任何帮助将不胜感激。

【问题讨论】:

  • 你遇到了什么错误?
  • 分享你正在使用的连接网址
  • DATABASE_URL=postgres://{user}:{password}@{hostname}:{port}/{database-name}
  • 它是相同的结构.. 没有端口,但我也尝试过它没有工作的端口
  • 请分享 postgresql.conf 文件

标签: postgresql docker gcloud


【解决方案1】:

您可能需要编辑 postgresql.confpg_hba.conf 文件。

postgresql.conf:

listen_addresses = '*'

pg_hba.conf file:

host    all         all         192.168.1.0/24        md5

【讨论】:

    猜你喜欢
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 2014-06-07
    • 2021-12-31
    • 2020-02-08
    • 2016-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多