# httpx.ConnectError: [Errno -2] Name or service not known while connecting to 'nonexistent.example.com'

- **ID:** `python/httpx-connecterror-dns-resolution-failure`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The hostname cannot be resolved by the system's DNS resolver.

## Version Compatibility

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

## Workarounds

1. **Use a working DNS server like Google's 8.8.8.8** (85% success)
   ```
   # On Linux: echo 'nameserver 8.8.8.8' > /etc/resolv.conf
# Or use socket.create_connection with IP address
   ```
2. **Replace hostname with IP address in the request** (70% success)
   ```
   httpx.get('http://93.184.216.34')  # example.com IP
   ```

## Dead Ends

- **Using a different DNS resolver in code without system changes** — httpx uses the system resolver by default; custom resolver requires extra setup. (80% fail)
- **Ignoring the error and retrying** — DNS failure persists across retries. (90% fail)
