pypa/pip · error · SSLVerificationError
ssl-verification-failed
ssl-verification-failed
Error message
Failed to establish a secure connection to {host} while fetching {url} What it means
Error "Failed to establish a secure connection to {host} while fetching {url}" thrown in pypa/pip.
Source
Thrown at src/pip/_internal/network/utils.py:180
Note: requests.ConnectionError is the parent class of
requests.ProxyError, requests.SSLError, and requests.ConnectTimeout
so these errors are also handled here.
"""
url = redact_auth_from_url(url)
raw_hostname = urlsplit(url).hostname or urlsplit(url).netloc
reason = error.args[0] if error.args else error
# NewConnectionError is a subclass of TimeoutError for some reason...
if isinstance(reason, urllib3.exceptions.TimeoutError) and not isinstance(
reason, urllib3.exceptions.NewConnectionError
):
# A bare timeout error can occur during non-streamed responses. Don't
# ask me how.
_raise_timeout_error(reason, url, raw_hostname, timeout)
if isinstance(reason, urllib3.exceptions.SSLError):
# A bare SSL error can occur during non-streamed responses, after the
# initial connection and TLS handshake have completed.
raise SSLVerificationError(url, raw_hostname, reason)
# At this point, all errors should be wrapped in MaxRetryError.
if not isinstance(reason, urllib3.exceptions.MaxRetryError):
raise ConnectionFailedError(url, raw_hostname, reason)
max_retry_error = reason
assert isinstance(max_retry_error.pool, urllib3.connectionpool.HTTPConnectionPool)
host = max_retry_error.pool.host
proxy = max_retry_error.pool.proxy
# Narrow the reason further to the specific error from the last retry.
reason = max_retry_error.reason
if isinstance(reason, urllib3.exceptions.SSLError):
raise SSLVerificationError(url, host, reason)
if isinstance(reason, urllib3.exceptions.TimeoutError) and not isinstance(
reason, urllib3.exceptions.NewConnectionError
):
_raise_timeout_error(reason, url, host, timeout)View on GitHub (pinned to d7d0d0a394)
When it happens
Trigger: Thrown at src/pip/_internal/network/utils.py:180 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/596ad64fddd2664e.json.
Report an issue: GitHub.