Common causes
- A slow or unstable connection, often on mobile, while uploading a file or a large request body.
- The upload takes longer than the server's body timeout.
- The
Content-Lengthheader is larger than the body actually sent, so the server waits for bytes that never arrive. - The browser opened a spare connection in advance and never used it. The server times it out and logs a 408, and the browser quietly opens a new connection when it needs one.
- A load balancer or proxy in front of the server closes connections that stay idle longer than its timeout.
Server timeout settings
Raise a timeout only for the routes that need it, such as an upload endpoint. Short timeouts elsewhere protect the server from clients that open connections and send slowly.
| Setup | Setting |
|---|---|
| nginx | client_header_timeout and client_body_timeout, both 60 seconds by default. |
| Apache | RequestReadTimeout from mod_reqtimeout, for example RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500. |
| Node.js | server.headersTimeout and server.requestTimeout on the HTTP server. |
| AWS Application Load Balancer | The idle timeout, 60 seconds by default. The load balancer returns 408 when the client sends nothing before it runs out. |
Retry a timed-out request
For large files, resumable or chunked uploads, such as S3 multipart uploads, avoid starting over after every timeout.
async function fetchWithRetry(url, options = {}, retries = 2) {
for (let attempt = 0; ; attempt++) {
const response = await fetch(url, options);
if (response.status !== 408 || attempt >= retries) return response;
await new Promise((resolve) => setTimeout(resolve, 500 * 2 ** attempt));
}
}Frequently asked questions
Is a 408 a client or a server problem?
The status says the client was too slow to send its request. But if many users on normal connections get it, the server's timeout may be too short for what they send.
Is it safe to retry after a 408?
The server didn't process the request, so repeating it is allowed. For requests that change data, such as payments, still use an idempotency key in case the first attempt partly went through.
Why are there 408s in my server logs that no user reported?
Browsers open connections ahead of time to load pages faster and close some unused. The server logs a 408 when those time out, but no request was lost and nobody saw an error.
More http status code lookup guides
- 502 Bad Gateway: What It Means and How to Fix It
- 504 Gateway Timeout: Causes and Fixes
- 429 Too Many Requests: Meaning, Retry-After and Fixes
- 403 Forbidden: Meaning, Causes and How to Fix It
- 401 Unauthorized: What It Means and How to Fix It
- 500 Internal Server Error: Causes and How to Fix It
- 503 Service Unavailable: Causes and Fixes
- 400 Bad Request: Causes and Fixes (Including Cookie Too Large)
- 404 Not Found: What It Means and How to Fix It
- 301 Moved Permanently: Meaning, SEO and Examples
- 302 Found: Temporary Redirects Explained