# aiohttp.client_exceptions.ClientOSError: [Errno 104] Connection reset by peer

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

## Root Cause

The remote server closed the TCP connection unexpectedly, often due to timeouts, server overload, or network issues.

## Version Compatibility

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

## Workarounds

1. **Implement retry logic with exponential backoff** (85% success)
   ```
   for attempt in range(3): try: async with session.get(url) as resp: return await resp.text(); except ClientOSError: await asyncio.sleep(2**attempt)
   ```
2. **Increase the TCP keepalive or use a longer timeout** (75% success)
   ```
   timeout = aiohttp.ClientTimeout(total=60); async with session.get(url, timeout=timeout) as resp: ...
   ```

## Dead Ends

- **Increasing the connector limit to allow more connections** — Connection reset is not related to pool size; it's a network-level issue. (40% fail)
- **Disabling SSL verification** — SSL is not the cause; this does not address TCP resets. (30% fail)
