How to fix ConnectTimeout error in Python requests
A ConnectTimeout means the client could not finish opening a connection to the host before its connect deadline expired.
The server never got far enough to send a response, so this is not the same problem as a slow page body. The fix depends on why the handshake stalled: a genuinely slow or distant host, a blocked IP, or a connect timeout set too aggressively for the network you are on.
What the error actually reports
Python requests raises ConnectTimeout when the target site does not answer the connection attempt within the allotted time. The request is abandoned during connection setup, before any HTTP response exists. That timing matters: raising a read timeout will not help here, because the read phase has not begun.
Reproducing it deliberately with a short connect timeout
You can force the condition against a site that normally loads by giving requests a very small connect deadline. The timeout argument accepts a tuple of (connect_timeout, read_timeout), both in seconds. A connect value of 0.1 second paired with a 10 second read value is tight enough that ordinary network latency can trip it, which makes it a useful way to see the exception in a controlled setting.
The two values in the timeout tuple
The tuple splits the deadline into two independent phases. The first number caps how long the client spends establishing the connection; the second caps how long it waits for data once connected. A ConnectTimeout points at the first number. A ReadTimeout points at the second. Adjusting the wrong one leaves the failure unchanged, so identify which phase failed before editing anything.
Applying the fix
If the site is reachable and your IP is not being blocked, the remedy is to raise the connect timeout. The corrected example keeps the 10 second read deadline and lifts the connect value to 6 seconds, giving a slow handshake room to complete while still bounding the wait. Choose a value that reflects real latency to the host rather than copying one blindly; a distant origin or a busy TLS handshake may need more headroom than a nearby one.
Check before you raise the number
Raising the connect timeout only helps when the connection is genuinely slow. Work through this order first: confirm the host resolves and responds from another client; check whether your IP is being blocked, since a block can present as a stalled connection; confirm the failure is at connect rather than read; and only then increase the connect value. If the site is fine and your address is not blocked, a longer connect deadline is the appropriate change.
Related requests errors and tutorials
Other common failures in the same library have their own causes and fixes, including SSL errors, missing URL schemes, read timeouts and redirect loops. Working through the related questions below helps you match the exception you actually received to the right remedy.
| Symptom | Phase that failed | Value to adjust | Captured example value |
|---|---|---|---|
| ConnectTimeout raised before any response | Connection setup | First tuple element (connect_timeout) | 0.1 s to simulate, 6 s to fix |
| ReadTimeout raised after connection | Waiting for response data | Second tuple element (read_timeout) | 10 s |
| Site loads elsewhere but not from your address | Possible IP block | Neither; investigate blocking first | Not applicable |
Values shown are the exact figures used in the captured examples, not recommended defaults for any particular host.
Frequently asked questions
Does raising the read timeout fix a ConnectTimeout?
No. A ConnectTimeout happens during connection setup, before the read phase starts, so the read value in the tuple is never reached. Change the first element of the timeout tuple instead.
How do I know my IP is not the problem?
Test the same URL from a different network or client. If it connects there but stalls from your address, treat blocking as the likely cause and investigate that before extending any timeout.
What does timeout=(0.1, 10) mean in requests?
It sets a 0.1 second deadline for establishing the connection and a 10 second deadline for receiving data afterwards. Both are expressed in seconds.
Is a longer connect timeout always the right answer?
No. It only helps when the handshake is genuinely slow. If the host is down or your IP is blocked, a longer deadline just makes the failure take more time to appear.