411 Length Required
The server refuses the request because it did not declare a Content-Length.
Status
HTTP/1.1 411 Length Required
Details
- Category: 4xx
- Status: Standard. Registered with IANA and defined by a current standards-track RFC.
- Specification: RFC 9110 §15.5.12
- Cacheable: Not cacheable
- Response body: Allowed
- Retry: Retry only after changing the request
Some servers will not accept a body of unknown size. If a request arrives without Content-Length and without chunked transfer encoding, they answer 411 rather than reading an unbounded stream.
It appears mostly with hand-built HTTP clients, with scripts that stream a body from a pipe, and with older servers that do not accept chunked uploads.
Headers
- Content-Length: The request header whose absence caused the rejection.
Common causes
- A POST or PUT sent with no Content-Length and no Transfer-Encoding: chunked.
- A body streamed from stdin or a generator whose size is not known in advance.
- A server or proxy that rejects chunked request bodies outright.
How to fix it
As the client
- Buffer the body, measure it, and set Content-Length.
- If you must stream, confirm the server accepts Transfer-Encoding: chunked before relying on it.
- In curl, use --data-binary @file rather than piping through stdin so the length is known.
As the server
- Accept chunked request bodies where practical, with a hard cap on total size.
- State the limit and the requirement in the error body.
Examples
POST /upload HTTP/1.1 Host: api.example.com Content-Type: application/octet-stream (body with no declared length) HTTP/1.1 411 Length Required