408 Request Timeout
The server did not receive the whole request within the time it was prepared to wait, so it gave up on it.
What 408 means
A 408 is about the request arriving too slowly, not about the response taking too long. The client opened a connection and then failed to deliver the complete headers or body in time. The server never got as far as doing any work.
That is why it sits in the 4xx class. A slow application behind a proxy is a 504; a client library that gives up waiting produces no status code at all, only a local timeout error.
The client may repeat the request, on a new connection. In HTTP/1.1 the old one is unusable, because the server can no longer tell where the unfinished request ends and the next would begin, so servers send Connection: close with a 408. Earlier versions of the specification asked for that explicitly.
The timeouts that produce it
| Server | Directive | Default |
|---|---|---|
| nginx | client_header_timeout | 60s to receive the complete request header |
| nginx | client_body_timeout | 60s between two successive reads of the body, not for the whole upload |
Apache (mod_reqtimeout) | RequestReadTimeout | header=20-40,MinRate=500 body=20,MinRate=500 |
The Apache default reads: 20 seconds for the headers, extended while data keeps arriving at 500 bytes per second or more, up to 40 seconds; 20 seconds for the body, extended in the same way without an upper limit.
These limits exist to stop slow-request attacks, in which a client opens many connections and feeds each a byte at a time to hold them open. Raising them makes the server easier to exhaust.
Why a real client hits it
- A large upload over a poor connection that stalls for longer than the body timeout. The total upload time does not matter; a gap does.
- A client that sends the headers and then spends a long time producing the body, for example compressing a file or running a query before it writes anything.
- A sleeping phone or laptop, or a network change in the middle of a request.
- An idle connection. Some servers and load balancers answer 408 as they close a connection on which no request arrived in time. Browsers open spare connections in advance, so these 408s appear in access logs with an empty request line and no user ever sees them.
Handling it
- As a client: retry once on a fresh connection. If uploads keep failing, send smaller pieces (a chunked or resumable upload protocol) and prepare the body before opening the connection.
- As a server owner: filter access-log 408s by request line. Empty ones are idle connections and can be ignored. For real uploads, raise
client_body_timeoutonly in thelocationthat receives them. - Do not send 408 from application code because your own processing was slow. For that, the honest codes are 503 or, from a gateway, 504.
408 compared with 504, 499 and 503
| Code | Who was slow | Who gave up |
|---|---|---|
| 408 Request Timeout | The client, sending the request | The server |
| 504 Gateway Timeout | The upstream, sending the response | A proxy |
| 499 (nginx) | The server or upstream, sending the response | The client, which disconnected |
| 503 Service Unavailable | Nobody | The server declined at once |
Example 408 response
HTTP/1.1 408 Request Timeout
Connection: close
Content-Type: text/plain; charset=utf-8
Content-Length: 38
The request was not completed in time.Connection: close tells the client that this connection is finished and a retry needs a new one.
Defined in RFC 9110, section 15.5.9.
Questions
What causes a 408 Request Timeout?
The client was too slow to send its request: a stalled upload, a dropped or sleeping connection, or a client that opened the connection and sent nothing. The server waited for its configured time and then closed the connection.
What is the difference between 408 and 504?
A 408 means the server timed out waiting for the client to send the request. A 504 means a proxy timed out waiting for the server behind it to send the response. The first is a slow client, the second a slow backend.
Should I retry after a 408?
Yes. The specification allows the client to repeat the request, and since the server never received it in full, nothing was processed. Use a new connection. If it fails again, the cause is probably the network path or the size of the upload.
Why does my access log show 408 with an empty request?
A client, usually a browser, opened a connection in advance and never used it. When the server's timeout expired it logged the unused connection as a 408. No request was lost and no user saw an error.