# ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/ (Caused by NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object>: Failed to establish a new connection: [Errno 111] Connection refused'))

- **ID:** `python/pip-connection-refused-proxy`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pip is honoring an HTTP(S) proxy from the environment (HTTP_PROXY/HTTPS_PROXY) that is unreachable or refusing connections.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Unset or correct the proxy env vars: `unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy` then retry, or set `proxy = http://user:pass@host:port` in pip.conf.
   ```
2. **** (85% success)
   ```
   Bypass the proxy for PyPI: `pip install --proxy "" <pkg>` (empty string disables proxy for this invocation).
   ```

## Dead Ends

- **** — Retries cannot succeed against a proxy that consistently refuses connections. (85% fail)
- **** — Trusted-host skips TLS verification, not proxy routing; the connection still fails. (90% fail)
