408 Request Timeout

Client Error - Server timed out waiting for request

HTTP 408 Request Timeout

What It Means

The HTTP 408 Request Timeout status code indicates that the server did not receive a complete request from the client within the time it was prepared to wait. The server is closing the connection.

408 vs 504

  • 408: Server waiting for client to send request
  • 504: Server waiting for upstream server to respond

Common Causes

  • Slow client connection: Poor network conditions
  • Large request body: Uploading big files on slow connection
  • Client paused: Application stopped sending data mid-request
  • Network interruption: Packet loss or connectivity issues
  • Keep-alive timeout: Idle connection timed out

Example Response

HTTP/1.1 408 Request Timeout
Connection: close
Content-Type: text/html

<html>
<body>
  <h1>Request Timeout</h1>
  <p>The server timed out waiting for your request.</p>
</body>
</html>

Server Configuration

Nginx

# Client request timeout settings
http {
    client_header_timeout 60s;  # Time to receive headers
    client_body_timeout 60s;    # Time to receive body
    send_timeout 60s;           # Time between writes
    keepalive_timeout 75s;      # Idle connection timeout
}

Apache

# Timeout for client to send request
Timeout 60

# Keep-alive settings
KeepAliveTimeout 5

Client-Side Handling

async function fetchWithRetry(url, options, retries = 3) {
  for (let i = 0; i < retries; i++) {
    try {
      const response = await fetch(url, options);
      if (response.status === 408) {
        console.log('Request timeout, retrying...');
        continue;
      }
      return response;
    } catch (error) {
      if (i === retries - 1) throw error;
    }
  }
}

Debugging Tips

  1. Check your network connection speed
  2. Try smaller payloads to isolate the issue
  3. Monitor request timing in browser DevTools
  4. Check server timeout configuration
  5. Look for network interruptions (VPN, proxy)

Prevention

  • Use chunked uploads for large files
  • Implement progress indicators for long uploads
  • Consider increasing timeout for slow endpoints
  • Add retry logic for transient failures

Monitor request timeouts

Track timeout errors and optimize your endpoints.

Start monitoring free →

Related Status Codes