411 Length Required
The server refuses the request because the mandatory Content-Length header is missing and chunked encoding wasn't used instead.
Defined in RFC 9110 §15.5.12
What 411 means
411 Length Required means the server refuses to accept the request because it lacks a Content-Length header, and the server insists on knowing the body's size before processing it rather than accepting chunked Transfer-Encoding as an alternative. RFC 9110 permits a server to make this demand for resources where knowing the exact size in advance genuinely matters, such as allocating storage or enforcing size limits before reading a single byte.
This is rare with modern HTTP client libraries, which set Content-Length automatically for buffered bodies or use chunked Transfer-Encoding for streamed ones, so 411 usually surfaces with hand-rolled HTTP requests, low-level socket code, or unusual client and proxy combinations where an intermediary strips the Content-Length header in transit without adding a chunked encoding in its place.
Because the vast majority of clients never trigger this, servers that enforce it strictly should do so only where the size is genuinely required upfront, for example to pre-allocate storage, and should return a clear, actionable error rather than a bare status code, since most developers encountering a 411 have never seen it before and won't immediately know what it means or how to fix it.
Common causes
- A custom or low-level HTTP client sent a request body without a Content-Length header.
- The body was streamed without chunked Transfer-Encoding and without a declared length.
- An intermediary proxy stripped the Content-Length header in transit.
- The server is configured to reject chunked encoding but requires Content-Length instead.
How to fix a 411
If you are the client (browser user or API caller)
- Set the Content-Length header explicitly, or use chunked Transfer-Encoding if the server supports it.
- Use a standard HTTP library rather than hand-crafting the request, so header framing is handled automatically.
- Check whether an intermediary proxy is stripping the Content-Length header before it reaches the server.
If you run the server
- Accept chunked Transfer-Encoding as an alternative to a declared Content-Length where feasible.
- Return an error body that names the missing header so unfamiliar clients can diagnose it quickly.
- Only enforce this requirement where the size genuinely must be known upfront, since most clients set it automatically.
Example
POST /upload HTTP/1.1
Host: api.example.com
Transfer-Encoding: identity
[body sent without Content-Length]
HTTP/1.1 411 Length Required
Content-Type: application/json
{"error": "length_required", "message": "Content-Length header is required for this endpoint"}Try it live
Our free status responder returns a real HTTP 411 you can point tests, monitors or a browser at.
GET https://mcp.httpstatus.com/status/411