# httpx.ConnectTimeout: Connection timed out after 5000ms to host 'api.example.com' (DNS resolution failed)

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

## Root Cause

The DNS server cannot resolve the hostname, possibly due to network misconfiguration or DNS server unavailability.

## Version Compatibility

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

## Workarounds

1. **Use an IP address directly instead of hostname** (70% success)
   ```
   client = httpx.Client()
response = client.get('http://93.184.216.34')
   ```
2. **Configure a custom DNS resolver in the system or use a different DNS server** (90% success)
   ```
   import socket
socket.setdefaulttimeout(10)
# Or change /etc/resolv.conf (Linux) or network settings (Windows)
   ```

## Dead Ends

- **Increasing timeout to a very high value** — Timeout increase does not fix DNS resolution; the request will still hang if DNS fails. (80% fail)
- **Restarting the application without checking DNS configuration** — The underlying DNS issue persists across restarts. (90% fail)
