408
Request Timeout
!
?

Example HTTP Response

HTTP Response
HTTP/1.1 408 Request Timeout
Connection: close
Common Causes
  • Client took too long to send request
  • Network issues causing delays
  • Server closing idle connections
Technical Details

What does this mean?

Hello? Anyone there? The server waited and waited but you took too long. Like a restaurant giving away your table.

Technical Definition

The server would like to shut down this unused connection.

RFC Says

"The 408 (Request Timeout) status code indicates that the server did not receive a complete request message within the time that it was prepared to wait. A server SHOULD send the 'close' connection option in the response, since 408 implies that the server has decided to close the connection rather than continue waiting."

Plain English:

408 means 'You took too long to send me the complete request.' This happens when a client starts sending a request but doesn't finish it within the server's timeout period. The server will typically close the connection after sending this response.

Common Misinterpretation

Don't use 408 for application-level timeouts (like a slow database query). Use 408 only when the HTTP request itself wasn't fully received in time. For slow operations, use 504 Gateway Timeout or handle it at the application level.

Code Snippets

Ready-to-use code for returning this HTTP status in your application:

Node.js
// Express.js
app.get('/example', (req, res) => {
  res.status(408).json({
    error: 'Request Timeout',
    message: 'Your error message here'
  });
});

// Native HTTP
const http = require('http');

http.createServer((req, res) => {
  res.writeHead(408, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    error: 'Request Timeout',
    message: 'Your error message here'
  }));
}).listen(3000);
Related Status Codes