python
network_error
ai_generated
true
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
ID: python/postgresql-unable-to-connect
80%Fix Rate
87%Confidence
0Evidence
2025-09-25First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.4.x | active | — | — | — |
| 2.0.x | active | — | — | — |
Root Cause
PostgreSQL 服务器未启动或监听在不同端口/地址。
generic中文
PostgreSQL 服务器未启动或监听在不同端口/地址。
Workarounds
-
90% success
启动 PostgreSQL 服务:systemctl start postgresql 或 service postgresql start
-
85% success
检查连接配置,确保主机、端口和数据库名称正确。
Dead Ends
Common approaches that don't work:
-
50% fail
尝试连接其他端口,但不知道服务器实际监听端口。
-
40% fail
禁用防火墙,但可能造成安全隐患。