python
network_error
ai_generated
true
sqlalchemy.exc.OperationalError:(psycopg2.OperationalError) 无法将主机名 "db.example.com" 转换为地址:名称解析临时失败
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "db.example.com" to address: Temporary failure in name resolution
ID: python/sqlalchemy-connection-ssl-error
80%修复率
85%置信度
0证据数
2025-11-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
数据库主机名的 DNS 解析失败。
English
DNS resolution failure for database hostname.
解决方案
-
90% 成功率 Check DNS configuration and network connectivity.
nslookup db.example.com ping db.example.com
-
85% 成功率 Use IP address temporarily and fix DNS.
engine = create_engine('postgresql://user:[email protected]/dbname')
无效尝试
常见但无效的做法:
-
Hardcoding IP address in connection string.
60% 失败
IP may change; not portable.
-
Increasing connection timeout.
80% 失败
DNS failure persists regardless of timeout.