408 Request Timeout means: The server timed out waiting for the complete request. The client opened a connection but did not finish sending headers/body within the server's idle window, so the server closes it; the client may retry the request on a new connection. Client-error 4xx codes mean the request itself is the problem: malformed syntax, missing credentials, forbidden access, a nonexistent resource or a violated precondition. The server is telling the client what to change; retrying the identical request without a fix will reproduce the same error. In practice you will meet 408 when a slow or flaky client network stalls mid-upload; a connection pool holds idle keep-alive connections past the server timeout; a load balancer idle timeout fires before the client finishes sending. On the client side, retry on a fresh connection; align keep-alive/idle timeouts below the server's, and check upload bandwidth for large bodies. On the server side, tune request-header and body timeouts to your traffic profile; ensure LB idle timeouts are consistent across hops to avoid premature 408s.
When 408 happens
- A slow or flaky client network stalls mid-upload
- A connection pool holds idle keep-alive connections past the server timeout
- A load balancer idle timeout fires before the client finishes sending
How to fix it
On the client
Retry on a fresh connection; align keep-alive/idle timeouts below the server's, and check upload bandwidth for large bodies.
On the server
Tune request-header and body timeouts to your traffic profile; ensure LB idle timeouts are consistent across hops to avoid premature 408s.
Should you retry?
Retryable on a fresh connection; the server never received the full request.
Debugging steps
When 408 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Read the error body first — well-designed APIs name the offending field or missing credential. Then diff your actual request, headers included, against the documented contract. For this code specifically, check whether the most common trigger applies to your situation: a slow or flaky client network stalls mid-upload. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.
Notes & gotchas
Most 408s in server logs are harmless: browsers and connection pools pre-open sockets that sit idle past the timeout. Alert on 408 rates tied to real requests, not on raw counts.
Examples
HTTP/1.1 408 Request Timeout
Connection: close
Content-Type: application/json
Content-Length: 97
{
"error": "request_timeout",
"message": "A slow or flaky client network stalls mid-upload"
} curl -i https://api.example.com/v1/resource # observe the 408 response and its headers const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 408) {
const problem = await res.json(); // read field-level details
// fix the request (credentials, payload, URL) — identical retries keep failing
throw new RequestError(problem);
} import requests
res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 408:
problem = res.json() # field-level error details
# correct the request before retrying — identical retries keep failing
raise RequestProblem(problem) Frequently asked questions
408 vs 504: who timed out?
408: the server gave up waiting for the client's request. 504: a gateway gave up waiting for the upstream server's response. Opposite directions.
Why do I see 408s in logs with no user complaint?
Browsers and pools pre-open connections; when they sit idle past the timeout the server logs 408 and closes. Usually harmless background noise.
Are 4xx errors always the client's fault?
By contract yes — the server asserts the request must change. In practice servers sometimes misuse 4xx for their own problems (e.g. 400 for internal validation bugs), so read the error body before blaming your client code.
Should I retry 4xx responses automatically?
Generally no: the server says the request must change. Exceptions are 408 (fresh connection), 425 (after handshake) and 429 (after Retry-After). Blind retries of 400/401/403/404 just burn quota.
Try the JSON Validator
Check JSON syntax and locate errors by line and column.