python
network_error
ai_generated
true
httpx.ConnectError: [Errno 111] Connection refused
ID: python/httpx-connect-error
80%Fix Rate
88%Confidence
0Evidence
2024-05-30First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
The target host/port is not accepting connections — the service is down, bound to a different interface, or a firewall is blocking.
generic中文
目标主机/端口未接受连接——服务已停止、绑定到其他接口或防火墙拦截。
Workarounds
-
95% success
Verify the service is reachable: curl -v http://host:port/ ss -tlnp | grep :port
-
90% success
In Docker Compose, use the service name (not localhost) as the host, and ensure depends_on with healthcheck.
-
85% success
Add a circuit breaker with tenacity and surface a clear error to callers.
Dead Ends
Common approaches that don't work:
-
85% fail
If the service is down, retries fail identically.
-
90% fail
TLS is not involved; the TCP connect fails before handshake.
-
95% fail
Connection refused is immediate, not a timeout.