# 错误：由于 OSError 无法安装包：HTTPSConnectionPool(host='pypi.org', port=443)：超过最大重试次数。原因：NewConnectionError，无法建立新连接：[Errno 111] 连接被拒绝。

- **ID:** `python/pip-connection-refused-proxy`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pip 正在使用环境中的 HTTP(S) 代理（HTTP_PROXY/HTTPS_PROXY），但该代理不可达或拒绝连接。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   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% 成功率)
   ```
   Bypass the proxy for PyPI: `pip install --proxy "" <pkg>` (empty string disables proxy for this invocation).
   ```

## 无效尝试

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