How to solve ReadTimeoutError HTTPSConnectionPoolhost'pypi.python.org', port443 with pip?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
The ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443) error means pip could not download a package because the connection to PyPI timed out. This happens when the network is slow, a proxy or firewall interferes, or the PyPI server is temporarily overloaded. The most reliable fix is increasing the timeout with --default-timeout, but you may also need to switch mirrors, configure proxy settings, or retry the installation.
The Error
The default pip timeout is 15 seconds. If the server does not respond within that window, pip raises this error and aborts the installation.
Fix 1: Increase the Timeout
You can make this permanent in your pip configuration:
Fix 2: Use a Different PyPI Mirror
If the main PyPI server is slow in your region, switch to a mirror:
Set a permanent mirror in pip config:
Fix 3: Retry the Installation
Transient network issues often resolve on retry:
Fix 4: Configure Proxy Settings
If you are behind a corporate proxy:
For pip config:
Fix 5: Download Package Manually
If the connection is consistently failing, download the wheel file manually and install it:
Or download to a directory and install from there:
Fix 6: Upgrade pip
Older versions of pip may have worse timeout handling and lack retry logic:
Fix 7: Use a VPN or Different Network
Fix 8: Disable IPv6
Some networks have broken IPv6 routing that causes timeouts:
Pip Configuration File Locations
| OS | Path |
| Linux/macOS (user) | ~/.pip/pip.conf or ~/.config/pip/pip.conf |
| Windows (user) | %APPDATA%\pip\pip.ini |
| Linux/macOS (global) | /etc/pip.conf |
| Virtualenv | $VIRTUAL_ENV/pip.conf |
Common Pitfalls
- Using
pypi.python.orginstead ofpypi.org: The old hostnamepypi.python.orgredirects topypi.org. If your pip version is very old, it may still use the old hostname, which can be slower. Upgrade pip to use the modern endpoint. - Proxy not set for HTTPS: Setting only
HTTP_PROXYwithoutHTTPS_PROXYdoes not cover PyPI connections, which use HTTPS. Always set both environment variables. - Firewall blocking port 443: Corporate firewalls may block outbound HTTPS. Check with your IT department or try
curl https://pypi.orgto verify connectivity. - Large package downloads: Packages like
tensorflow,torch, andscipyare hundreds of megabytes. Even a working connection may time out with the default 15-second timeout. Set--default-timeout=300or higher for large packages. - Virtual environment isolation: Pip config files inside a virtualenv override global settings. If you set a timeout globally but still get timeouts in a venv, check
$VIRTUAL_ENV/pip.conffor conflicting settings.
Summary
- Increase timeout with
pip install pkg --default-timeout=100 - Use a PyPI mirror with
-i https://mirror-url/simple/ - Add
--retries 5for transient failures - Configure proxy with
--proxyorHTTP_PROXY/HTTPS_PROXYenvironment variables - Download packages manually with
pip downloadfor persistent connectivity issues - Upgrade pip to the latest version for better timeout and retry handling
Related reading
- How to sort a list of lists by a specific index of the inner list?
- How to sort a list of strings numerically
- How to sort a list/tuple of lists/tuples by the element at a given index
- How to sort a pandas dataFrame by two or more columns?
- How to solve String interpolation produces a debug description for an optional value; did you mean to make this explicit? in Xcode 8.3 beta?
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- How to sort Counter by value? - python
- How to sort mongodb with pymongo
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.