HTTP status code lookup

408 Request Timeout: Causes and How to Fix It

A 408 Request Timeout means the server closed the connection because the client didn't finish sending its request in time. The server was still waiting for the headers or the body.

Unlike 504 Gateway Timeout, where a proxy waits too long for the server behind it, a 408 is about the client's side of the connection: a slow network, a large upload or a connection left open and unused.

408

Request Timeout

The server timed out waiting for the client to finish sending the request.

Look up any other status code →

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-Length header 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.

SetupSetting
nginxclient_header_timeout and client_body_timeout, both 60 seconds by default.
ApacheRequestReadTimeout from mod_reqtimeout, for example RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500.
Node.jsserver.headersTimeout and server.requestTimeout on the HTTP server.
AWS Application Load BalancerThe 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

Open the full http status code lookup →

From the blog