411 Length Required 4xx
The server requires a Content-Length header, which the client did not provide.
What does 411 mean?
A 411 Length Required response means the server refuses to accept the request because it lacks a defined Content-Length header, and the server requires one to process requests of this kind. Content-Length tells the server exactly how many bytes to expect in the request body — some servers insist on knowing this upfront, particularly for certain types of requests, rather than reading an indefinite stream.
This code is relatively rare in modern HTTP, since Content-Length is set automatically by virtually all HTTP client libraries and browsers for requests with a body. It's more likely to surface when working with low-level HTTP implementations, custom clients, or chunked transfer encoding in contexts where the server doesn't support or accept it as an alternative.
How a 411 behaves
- It's specifically about the absence of
Content-Length, not about the value being too large (that would be 413) or the body being malformed - It can carry a body with a brief explanation
- The fix is purely about adding a header — the rest of the request might be entirely valid otherwise
- Some servers accept
Transfer-Encoding: chunkedas an alternative to a fixedContent-Length(since chunked encoding doesn't require knowing the total size upfront) — a 411 can indicate the server doesn't support this alternative for the given request
Common causes
If you're building/operating the server:
- Your server configuration requires
Content-Lengthfor certain request types and doesn't accept chunked transfer encoding as an alternative for those endpoints
If you're calling an API:
- You're using a low-level HTTP client or custom implementation that isn't automatically setting
Content-Lengthfor requests with a body - You're using chunked transfer encoding (
Transfer-Encoding: chunked) and the server doesn't accept this as a substitute forContent-Lengthon this endpoint
If you're a website visitor:
- Essentially never encountered directly — this is a low-level HTTP detail handled automatically by browsers
How to fix it
As an API/website builder:
- If your server requires
Content-Length, ensure this requirement is documented for API consumers using custom/low-level clients - Consider whether accepting
Transfer-Encoding: chunkedas an alternative would reduce friction for clients that stream request bodies without knowing the total size in advance
As an API consumer:
- If using a low-level HTTP implementation, ensure
Content-Lengthis being set correctly based on the actual size of your request body - If streaming a request body where the total size isn't known upfront, check whether the server supports
Transfer-Encoding: chunkedas an alternative
As a website visitor:
- Not applicable — this is handled automatically by browsers and isn't something end users encounter or need to address
411 vs 413
| 411 Length Required | 413 Payload Too Large | |
|---|---|---|
| What's the issue | The Content-Length header is missing entirely |
The body (whose size is known) exceeds an allowed limit |
| Fix | Add the Content-Length header (or use an accepted alternative) |
Reduce the size of the body, or split into smaller requests |
Real-world examples
411 is rarely encountered in modern web development, since virtually all HTTP client libraries (browsers' fetch/XHR, curl, language-specific HTTP libraries) automatically calculate and set Content-Length for requests with bodies. It's more likely to appear in niche scenarios — custom network programming, certain proxy/gateway configurations, or specific server software with stricter-than-typical requirements around streaming uploads.
SEO implications
None — 411 relates to low-level request header requirements for requests with bodies, entirely unrelated to page-level content or crawling.
FAQ
Why would a server require Content-Length at all?
Knowing the exact size of an incoming request body upfront can simplify server-side processing, buffering, and resource allocation — some server configurations or specific endpoints are set up to require this rather than handling a body of unknown length via chunked encoding.
Is 411 something I'm likely to encounter using a normal HTTP library?
Very unlikely — modern HTTP client libraries handle Content-Length automatically for any request with a body. 411 is mostly relevant to low-level/custom HTTP implementations or specific server configurations.
What's the relationship between 411 and chunked transfer encoding?
Transfer-Encoding: chunked is an alternative to Content-Length that allows a client to send a body without knowing its total size upfront, by sending it in chunks with explicit boundaries. A 411 can indicate the server doesn't accept this alternative for the request in question and insists on a fixed Content-Length.
Does 411 mean my request body is invalid?
No — it specifically means the header indicating the body's length is missing, independent of whether the body's actual content would otherwise be valid.
How do I fix a 411 in my own code?
If you're constructing HTTP requests manually (rather than via a standard library that handles this automatically), ensure you're calculating and including a Content-Length header matching the actual byte length of your request body.
Fun fact
411 is one of the most rarely-encountered status codes in everyday development specifically because the problem it addresses has been almost entirely automated away — modern HTTP libraries handle Content-Length so reliably and invisibly that many developers go their entire careers without ever triggering or even hearing about this status code, despite it being part of the core specification since early HTTP/1.1.