📏
411
Length Required
!
?

Example HTTP Response

HTTP Response
HTTP/1.1 411 Length Required
Content-Type: application/json

{"error": "Content-Length header required"}
Common Causes
  • Missing Content-Length header
  • Chunked encoding not supported
  • Server requires content length for processing
Technical Details

What does this mean?

How much are you sending? The server needs to know the size upfront. No mystery packages allowed!

Technical Definition

The server refuses to accept the request without a defined Content-Length header.

RFC Says

"The 411 (Length Required) status code indicates that the server refuses to accept the request without a defined Content-Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message body in the request message."

Plain English:

411 means 'You need to tell me how big your request body is by including a Content-Length header.' This is rarely needed in modern applications since most HTTP clients automatically include Content-Length.

Common Misinterpretation

You almost never need to return 411 in modern APIs. Most HTTP libraries handle Content-Length automatically. Only use 411 if you're building low-level HTTP infrastructure that specifically requires Content-Length for chunked transfer encoding decisions.

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(411).json({
    error: 'Length Required',
    message: 'Your error message here'
  });
});

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

http.createServer((req, res) => {
  res.writeHead(411, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    error: 'Length Required',
    message: 'Your error message here'
  }));
}).listen(3000);