# aiohttp.client_exceptions.ClientConnectorDNSError: Cannot resolve hostname example.com

- **ID:** `python/aiohttp-client-connector-resolver-error`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

DNS resolution failed for the given hostname, possibly due to network issues or invalid domain.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## Workarounds

1. **Check DNS configuration and use a custom resolver** (85% success)
   ```
   from aiohttp.resolver import AsyncResolver
resolver = AsyncResolver(nameservers=['8.8.8.8', '8.8.4.4'])
connector = aiohttp.TCPConnector(resolver=resolver)
async with aiohttp.ClientSession(connector=connector) as session:
   ```
2. **Implement retry with DNS fallback** (80% success)
   ```
   import socket
try:
    socket.gethostbyname('example.com')
except socket.gaierror:
    # fallback to IP or alternative hostname
   ```

## Dead Ends

- **Using IP address directly instead of hostname** — IP addresses may change, and SSL certificates may not match, causing other errors. (50% fail)
- **Adding a custom hosts file entry without proper validation** — The entry may be incorrect or overridden by system settings. (40% fail)
