HTTP 408 Request Timeout — Causes, Fix & Server Configuration
The server timed out waiting for the request. The client did not send a complete request within the time the server was prepared to wait. The client may repeat the request without changes.
When to Return 408
Typically sent by the server infrastructure (nginx, load balancers) rather than application code. Implement in application code when processing has a maximum time budget and the client's connection stalled.
Common Causes
- Client connection dropped mid-request
- Slow network causing request body to arrive slowly
- Large file upload stalled
- Client opened connection but never sent headers
HTTP Response Example
HTTP/1.1 408 Request Timeout
Connection: close
Content-Type: application/json
{"error": "Request Timeout"}Code Examples
Express.js
// Usually set by server config, not app code.
// In Express, configure the underlying http server:
const server = app.listen(3000)
server.setTimeout(30_000) // 30 second request timeout
// Or in middleware:
app.use((req, res, next) => {
req.setTimeout(30_000, () => {
res.status(408).json({ error: 'Request Timeout' })
})
next()
})Next.js App Router
// next.config.ts — server actions and API routes have no default timeout.
// Set per-route with the maxDuration export:
export const maxDuration = 30 // 30 seconds (Vercel / Node.js runtime)Related Status Codes
Frequently Asked Questions
What does HTTP 408 Request Timeout mean?
The server timed out waiting for the request. The client did not send a complete request within the time the server was prepared to wait. The client may repeat the request without changes.
When should an API return 408?
Typically sent by the server infrastructure (nginx, load balancers) rather than application code. Implement in application code when processing has a maximum time budget and the client's connection stalled.
What causes an HTTP 408 error?
Common causes: Client connection dropped mid-request; Slow network causing request body to arrive slowly; Large file upload stalled; Client opened connection but never sent headers.
