# aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

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

## Root Cause

The remote server closed the TCP connection before sending a complete response, often due to keep-alive timeouts, server-side crashes, or proxy interference.

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   Enable retries with exponential backoff using aiohttp's built-in retry or a custom decorator:

from aiohttp_retry import RetryClient, ExponentialRetry
retry_options = ExponentialRetry(attempts=3)
async with RetryClient(retry_options=retry_options) as client:
    await client.get(url)
   ```
2. **** (70% success)
   ```
   Set a Connection: close header to avoid keep-alive reuse:

headers = {'Connection': 'close'}
async with session.get(url, headers=headers) as resp:
    ...
   ```

## Dead Ends

- **** — The disconnect is not caused by slowness; a longer timeout just delays the failure. (60% fail)
- **** — The error is at the TCP layer, not TLS; disabling SSL does not prevent the server from closing the connection. (80% fail)
