Set a timeout on every production call you make with requests. Use one number when the same limit is acceptable for connection and response data, or a tuple such as (3.05, 27) when connection setup and waiting for response bytes need different limits. Catch requests.exceptions.Timeout (or its ConnectTimeout and ReadTimeout subclasses), and treat retries as a separate policy. A Requests timeout is not an end-to-end deadline for downloading an entire response.
What a Requests timeout actually controls
Requests has no default timeout. If you omit timeout, a stalled connection can wait indefinitely, which is why the official Quickstart says nearly all production requests should specify it. The value controls socket inactivity: how long the underlying connection may go without receiving data.
That distinction matters. A server can send a few bytes periodically and keep a request alive beyond your intended user-facing latency budget. Likewise, a large response can take longer than the timeout while remaining active. If you need a strict wall-clock deadline, enforce one outside Requests (for example, with a worker deadline or an application-level timer) rather than treating timeout as a total download cap.
See the Requests Quickstart and Advanced Usage timeout guidance for the documented behavior.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Choose separate connection and read limits
One value
requests.get(url, timeout=10) applies 10 seconds to both connection establishment and waiting for response data. It is concise, but it hides which phase is slow.
A tuple
Pass (connect_timeout, read_timeout) to express the two phases directly:
import requests
response = requests.get(
"https://api.example.com/data",
timeout=(3.05, 27),
)
response.raise_for_status()
print(response.json())
Here, the client allows about 3.05 seconds to establish a connection and 27 seconds between response-data arrivals. Those values are examples, not universal recommendations. Choose them from the service’s normal latency, your caller’s latency budget, and the cost of waiting.
Why connect time can exceed the number
Connect and read values are not wall-clock guarantees. A hostname may resolve to multiple IP addresses; connection attempts can occur in sequence, so the effective setup time can exceed the configured connect value. Account for this when setting an outer deadline.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsCatch the right exception
Timeout exceptions are transport failures, not HTTP status failures. Requests exposes a hierarchy that lets you handle all timeouts together or distinguish their cause.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
ConnectTimeout: connection establishment did not complete in time. Requests documents this case as safe to retry.ReadTimeout: the server did not provide response data within the read interval.Timeout: common superclass for both; use it when the distinction is not needed.ConnectionError: broader network failures such as DNS errors or refused connections.HTTPError: raised byraise_for_status()for an unsuccessful HTTP status; it is unrelated to a transport timeout.
import requests
try:
response = requests.get(
"https://api.example.com/data",
timeout=(3.05, 27),
)
response.raise_for_status()
except requests.exceptions.ConnectTimeout:
# No connection was established in the connect interval.
print("Connection timed out")
except requests.exceptions.ReadTimeout:
# No response bytes arrived in the read interval.
print("Read timed out")
except requests.exceptions.Timeout:
# Handles either timeout subtype if not handled above.
print("Request timed out")
except requests.exceptions.ConnectionError as exc:
print(f"Network error: {exc}")
except requests.exceptions.HTTPError as exc:
print(f"HTTP failure: {exc}")
Put the specific subclasses before Timeout; otherwise the superclass branch catches them first. Keep status handling separate: a response with a 500 status is still a response, while a timeout means the expected transport step did not complete.
Use a session and apply a consistent policy
A small wrapper prevents one forgotten call from reintroducing an infinite wait:
from typing import Any
import requests
session = requests.Session()
def get_json(url: str, *, params: dict[str, Any] | None = None) -> Any:
try:
response = session.get(url, params=params, timeout=(3.05, 20))
response.raise_for_status()
return response.json()
except requests.exceptions.Timeout:
# Record the URL and operation, then let the caller decide what to do.
raise
Use a shorter read timeout for interactive requests and a longer one for a deliberately slow report endpoint. Do not silently return partial data after a timeout. If you use stream=True, remember that iterating over the body is a separate stage; the same inactivity rule applies while reading chunks.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Retries: configure them deliberately
Requests does not retry failed connections by default. For controlled retries, mount an HTTPAdapter configured with urllib3.util.Retry:
import requests
from requests.adapters import HTTPAdapter
from urllib3.util import Retry
retry = Retry(
total=3,
connect=3,
read=0,
status=2,
backoff_factor=0.5,
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods={"GET", "HEAD", "OPTIONS"},
respect_retry_after_header=True,
)
session = requests.Session()
adapter = HTTPAdapter(max_retries=retry)
session.mount("https://", adapter)
session.mount("http://", adapter)
response = session.get(
"https://api.example.com/data",
timeout=(3.05, 20),
)
response.raise_for_status()
The counts and backoff above are an example policy. Adjust them to the service and operation. A timeout can happen after a server has received a request; retrying a non-idempotent POST can create a duplicate action. Restrict automatic retries to operations you can safely repeat, or use an idempotency key supplied by the API. The adapter’s basic integer retry behavior covers failed DNS lookups, socket connections, and connection timeouts, not cases where request data reached the server. Consult the HTTPAdapter reference and urllib3 retry documentation for the version you deploy.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Design timeouts from an actual latency budget
Interactive web request
Reserve most of the budget for the remote service but keep connection setup small, for example (2, 5). Return a useful fallback when the deadline is exceeded rather than blocking the user interface.
Background synchronization
A longer read interval can be appropriate, but still set a finite value and log elapsed time. Let a job runner enforce its own overall deadline so one repeatedly slow endpoint cannot consume the whole worker.
Large or streamed responses
The timeout does not cap total transfer time. Consume the stream incrementally, enforce your own total deadline if required, and close the response in a context manager:
import requests
with requests.get(
"https://example.com/archive.zip",
stream=True,
timeout=(3.05, 30),
) as response:
response.raise_for_status()
with open("archive.zip", "wb") as output:
for chunk in response.iter_content(chunk_size=1024 * 64):
if chunk:
output.write(chunk)
Diagnose a timeout instead of guessing
- Identify the phase. A
ConnectTimeoutpoints to DNS, routing, firewall, TLS, or an overloaded listener; aReadTimeoutpoints to server processing or a stalled response. - Record context. Log the operation name, host, timeout tuple, attempt number, and elapsed time. Avoid logging authorization headers or sensitive query values.
- Check status separately. If a response exists, inspect
response.status_codeor callraise_for_status(); do not classify every failure as a timeout. - Reproduce outside the application. Compare the endpoint with a command-line client or service health check, then inspect DNS, proxy, TLS, and firewall behavior.
- Check retry consequences. Verify whether the server could have completed the operation before deciding to repeat it.
Common mistakes and fixes
Omitting timeout
Symptom: workers remain stuck. Fix: pass a finite value on every external call or centralize calls in a wrapper.
Using a timeout as a total deadline
Symptom: a download exceeds the expected maximum despite a small timeout. Fix: remember that the value limits socket inactivity; add an outer deadline for total elapsed time.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Retrying every exception
Symptom: duplicate writes or traffic spikes. Fix: retry only transient, safe operations and selected status codes.
Catching only HTTPError
Symptom: transport failures escape the handler. Fix: catch Timeout and other connection exceptions separately from HTTP status errors.
Setting an unrealistically low read value
Symptom: healthy but slow endpoints fail intermittently. Fix: measure normal latency, include network variation, and choose a value that matches the caller’s real budget.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your workflow also needs a dependable screenshot of a URL, ScreenshotNeo provides a single HTTP call instead of maintaining browser automation. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for the complete parameter list. You can also use Python:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
There are 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Quick decision checklist
- Did every external Requests call receive an explicit timeout?
- Should connection and read limits differ? If so, use a tuple.
- Is your required limit an overall wall-clock deadline? Add an outer deadline.
- Is the operation safe to repeat after a possible server-side execution?
- Are timeout, connection, and HTTP-status errors logged and handled separately?
- Are streamed downloads closed and monitored while chunks are consumed?
Frequently Asked Questions
What is the default timeout in Python Requests?
There is no default timeout. Without an explicit value, a request can wait indefinitely.
Is timeout=10 a ten-second total limit?
No. It applies to connection setup and socket inactivity while reading, not total response-download time.
When should I catch ConnectTimeout instead of Timeout?
Catch ConnectTimeout when connection-specific handling or retry decisions matter; use Timeout for common handling of both connection and read timeouts.
Does Requests retry a timed-out request automatically?
No. Configure an HTTPAdapter with urllib3 Retry, and limit retries to safe operations and deliberately selected conditions.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

