411

Length Required

4xx Client Error

ELI5

You're trying to send me something, but you didn't tell me how big it is. I need to know the size before I can accept it.

Server perspective

Use 411 when the server refuses to accept the request without a defined Content-Length.

When to use

  • Return 411 when the endpoint requires a known body length in advance
  • Use it when chunked or streaming request semantics are not accepted for that operation
  • Server requires Content-Length for processing
  • Upload endpoints that need size validation
  • Streaming requests without proper headers
  • Security policies requiring content length

How to respond

  • Explain that Content-Length is required
  • Document whether chunked transfer encoding is supported as an alternative

Headers to consider

  • Content-Length

Response body

  • Optionally include a concise error explaining that an accepted Content-Length or transfer mode is required.

Server-side pitfalls

  • Do not require Content-Length when your server already supports the transfer mode being used
  • Do not use 411 for requests that do not meaningfully send a body
  • Chunked transfer encoding is supported
  • GET requests (no body expected)
  • Content size is properly specified

Examples

File upload without Content-Length

Request:POST https://api.example.test/api/upload
Response:411 Length Required # Headers Content-Type: application/json # Body { "error": "content_length_required" }

Server requires Content-Length header to process the upload

References

Related Status Codes