HTTP 408 Request Timeout vs 502 Bad Gateway
HTTP 408 (Request Timeout) is a 4xx Client Error response, while 502 (Bad Gateway) is a 5xx Server Error response. 408 indicates that the server timed out waiting for the request. The client did not produce a request within the time the server was prepared to wait. In contrast, 502 means that the server, acting as a gateway or proxy, received an invalid response from the upstream server.
Description
The server timed out waiting for the request. The client did not produce a request within the time the server was prepared to wait.
When You See It
When a client takes too long to send the complete request (slow upload, network issues).
How to Fix
Retry the request. Check your network connection. Reduce request payload size.
Description
The server, acting as a gateway or proxy, received an invalid response from the upstream server.
When You See It
When Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).
How to Fix
Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.
Key Differences
408 is a 4xx Client Error response, while 502 is a 5xx Server Error response.
HTTP 408: The server timed out waiting for the request. The client did not produce a request within the time the server was prepared to wait.
HTTP 502: The server, acting as a gateway or proxy, received an invalid response from the upstream server.
You encounter 408 when when a client takes too long to send the complete request (slow upload, network issues).
You encounter 502 when when Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).
When to Use Which
For 408 (Request Timeout): Retry the request. Check your network connection. Reduce request payload size. For 502 (Bad Gateway): Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.