HTTP 408 Request Timeout
4xx Client Error
- Home
- HTTP Status Codes
- 4xx
- 408
What is HTTP 408 Request Timeout?
The 408 (Request Timeout) status code indicates that the server did not receive a complete request message within the time it was prepared to wait. This typically occurs when the client takes too long to send the request body or when an idle connection is terminated by the server.
Common Use Cases
- Slow client connections
- Long-running file uploads that exceed timeout
- Idle connection timeout in APIs
Usage Example
When implementing file upload endpoints, configure appropriate timeout values in your web server and application. If a client's upload exceeds the timeout, the server returns 408 and closes the connection. The client should retry with a chunked upload strategy or improved connection stability.
# Nginx - increase timeout for upload endpoints
client_body_timeout 300s;
proxy_read_timeout 300s;
# PHP - set max execution time
set_time_limit(300);
Related Status Codes
Common Mistakes
Mistake: Confusing 408 (client timeout) with 504 (gateway timeout)
Fix: Use 408 when the client takes too long to send its request. Use 504 when your server (as a gateway) waits too long for an upstream server response.
Mistake: Returning 408 after already partially processing the request
Fix: If the server has already started processing the request, it should complete if possible. 408 should only be sent before the server begins processing.