Why This Happens
httpx distinguishes connect timeout from read timeout. A read timeout means the connection was established but the server was too slow sending data.
The Problem
import httpx
client = httpx.Client()
response = client.get('https://slow-api.example.com')The Fix
import httpx
client = httpx.Client(timeout=httpx.Timeout(10.0, read=30.0))
try:
response = client.get('https://slow-api.example.com')
except httpx.ReadTimeout:
print('Server too slow')Step-by-Step Fix
- 1
Increase read timeout
Set httpx.Timeout(connect=5.0, read=30.0).
- 2
Handle timeout exceptions
Catch httpx.ReadTimeout for fallback.
- 3
Stream large responses
Use client.stream() for large data.
Got the actual stack trace?
Paste it into our free AI explainer to get the cause and the fix for your specific case — no signup, nothing to install.
Explain my errorBugsly catches this automatically
Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.
Try Bugsly free