# ERROR: Could not install packages due to a ConnectionError: [Errno 104] Connection reset by peer

- **ID:** `pip/network-connection-reset-by-peer`
- **Domain:** pip
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

The TCP connection to the PyPI server or mirror is abruptly closed by the remote host, typically due to firewall rules, load balancer timeouts, or network instability.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pip 20.0+ | active | — | — |
| Python 3.6-3.12 | active | — | — |

## Workarounds

1. **Use a different PyPI mirror with retries: pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple --retries 5 <package>** (85% success)
   ```
   Use a different PyPI mirror with retries: pip install --index-url https://pypi.tuna.tsinghua.edu.cn/simple --retries 5 <package>
   ```
2. **Increase the socket timeout to avoid premature resets: pip install --default-timeout=120 <package>** (75% success)
   ```
   Increase the socket timeout to avoid premature resets: pip install --default-timeout=120 <package>
   ```
3. **Use pip's --proxy option if behind a corporate proxy: pip install --proxy http://user:pass@proxy:8080 <package>** (80% success)
   ```
   Use pip's --proxy option if behind a corporate proxy: pip install --proxy http://user:pass@proxy:8080 <package>
   ```

## Dead Ends

- **** — The network condition is transient but repeating the exact same request often hits the same reset due to caching or persistent firewall state. (80% fail)
- **** — Overly aggressive and may expose the system to security risks; the issue may be on the server side, not local. (50% fail)
- **** — VPNs can introduce additional latency or packet loss, making the connection reset more likely. (65% fail)
