# 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`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The hostname cannot be resolved to an IP address because it does not exist or DNS is misconfigured.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Verify the hostname spelling and domain existence** (90% success)
   ```
   Check the URL for typos, e.g., requests.get('https://example.com') instead of 'exampl.com'
   ```
2. **Use a public DNS server like 8.8.8.8** (80% success)
   ```
   Configure system DNS to 8.8.8.8 or use socket.setdefaulttimeout(10) with a custom resolver
   ```

## Dead Ends

- **Increasing the retry count** — Retrying does not fix DNS resolution; the hostname remains unresolved. (95% fail)
- **Using a VPN or proxy without checking DNS** — A VPN may change DNS servers, but if the hostname is invalid, it still fails. (70% fail)
