python
network_error
ai_generated
true
requests.exceptions.ConnectionError: HTTPConnectionPool(host='nonexistent.example.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x...>: Failed to establish a new connection: [Errno -2] Name or service not known'))
ID: python/requests-connectionerror-dns-failure
80%Fix Rate
84%Confidence
0Evidence
2024-05-12First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
The hostname cannot be resolved to an IP address because it does not exist or DNS is misconfigured.
generic中文
主机名无法解析为IP地址,因为它不存在或DNS配置错误。
Workarounds
-
90% success Verify the hostname spelling and domain existence
Check the URL for typos, e.g., requests.get('https://example.com') instead of 'exampl.com' -
80% success Use a public DNS server like 8.8.8.8
Configure system DNS to 8.8.8.8 or use socket.setdefaulttimeout(10) with a custom resolver
Dead Ends
Common approaches that don't work:
-
Increasing the retry count
95% fail
Retrying does not fix DNS resolution; the hostname remains unresolved.
-
Using a VPN or proxy without checking DNS
70% fail
A VPN may change DNS servers, but if the hostname is invalid, it still fails.