# httpx.ConnectError: [Errno 104] Connection reset by peer while connecting to 'https://unstable.example.com'

- **ID:** `python/httpx-connecterror-connection-reset-by-peer`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

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

## Version Compatibility

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

## Workarounds

1. **Implement retry with exponential backoff and jitter** (85% success)
   ```
   import time, random
for i in range(3):
    try:
        response = httpx.get('https://unstable.example.com')
        break
    except httpx.ConnectError:
        time.sleep(2 ** i + random.uniform(0, 1))
   ```
2. **Use a connection pool with keep-alive to reduce connection resets** (70% success)
   ```
   client = httpx.Client()
response = client.get('https://unstable.example.com')
   ```

## Dead Ends

- **Retrying immediately without any delay** — The server may still be overloaded, causing immediate reset again. (80% fail)
- **Using a different HTTP version** — The issue is at the TCP level, not HTTP version. (90% fail)
