【问题标题】:psycopg2.OperationalError: could not translate host name "xxxxxx.us-east-1.rds.amazonaws.com" to address: Unknown hostpsycopg2.OperationalError:无法将主机名“xxxxxx.us-east-1.rds.amazonaws.com”转换为地址:未知主机
【发布时间】:2021-03-04 10:57:21
【问题描述】:

由于某种原因,我无法通过 psycopg2 连接到 PostgreSQL 数据库

这是我的连接配置:

conn = psycopg2.connect(
    user = "postgres",
    password = "xxxxxx",
    host = "xxxx.us-east-1.rds.amazonaws.com",
    database = "current2",
    port = 5432
)

我将敏感信息放在 x 中,但忽略了这一点,我到底做错了什么?

【问题讨论】:

    标签: python postgresql debugging psycopg2


    【解决方案1】:

    这是您的域名解析 (DNS) 设置错误,与数据库无关。您在系统上配置的 DNS 服务器无法解析主机名。

    要么使用不同的 DNS 服务器,要么使用数据库服务器的 IP 地址。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-16
      • 2021-03-27
      • 1970-01-01
      • 1970-01-01
      • 2021-08-26
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      相关资源
      最近更新 更多