# aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

- **ID:** `python/aiohttp-serverdisconnectederror`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The remote server closed the TCP connection before sending a complete HTTP response, often due to keep-alive timeouts, load balancer idle limits, or server-side crashes.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9+ | active | — | — |

## Workarounds

1. **** (85% success)
   ```
   import aiohttp

connector = aiohttp.TCPConnector(limit=100, enable_cleanup_closed=True)
async with aiohttp.ClientSession(connector=connector) as s:
    for attempt in range(3):
        try:
            async with s.get(url) as r:
                return await r.text()
        except aiohttp.ServerDisconnectedError:
            continue
   ```
2. **** (80% success)
   ```
   connector = aiohttp.TCPConnector(keepalive_timeout=15)
# plus exponential backoff wrapper around the request
   ```

## Dead Ends

- **** — The disconnect is server-initiated, not a client timeout; longer timeouts just make failures slower. (75% fail)
- **** — If the server closes mid-response, disabling keep-alive does not prevent the in-flight disconnect. (60% fail)
