python
system_error
official
true
ConnectionError
ID: python/connectionerror
80%Fix Rate
95%Confidence
0Evidence
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
A network connection failed. This is the base class for BrokenPipeError, ConnectionAbortedError, ConnectionRefusedError, and ConnectionResetError.
genericOfficial Documentation
https://docs.python.org/3/library/exceptions.htmlWorkarounds
-
90% success Implement exponential backoff with jitter for retries
Use urllib3.Retry or tenacity library; retry with 2^n seconds delay
-
90% success Check network connectivity and DNS resolution before connecting
socket.gethostbyname(host) or ping to verify reachability
Dead Ends
Common approaches that don't work:
-
Infinite retry without backoff
80% fail
Can overwhelm servers and trigger rate limiting; wastes resources