python network_error ai_generated true

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-06-25First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

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

generic

中文

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

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

Common approaches that don't work:

  1. 85% fail

    Retries cannot succeed against a proxy that consistently refuses connections.

  2. 90% fail

    Trusted-host skips TLS verification, not proxy routing; the connection still fails.