Utilo

HTTP 411 Length Required – Free, Online, Private

411 Length Required means the server refuses the request without a Content-Length.

What HTTP 411 means

411 says the server will not accept the request until the client sends Content-Length. Chunked transfer encoding is the usual reason a body has no length. Some servers, especially older ones and some upload endpoints, refuse chunked bodies. The client must buffer, count, and retry with a length. The status is not a validation error in the body.

411 Length Required belongs to the 4xx client error class. Clients that only look at the class will group it with its neighbors. Clients that care about the exact code should use the narrower rule on this page, because the class is only the first digit.

When you see HTTP 411

When you see HTTP 411 Length Required, stop on that exact status line. 411 Length Required means the server refuses the request without a Content-Length. The trace that usually produces it: A client used chunked encoding and the origin rejects it. The 4xx client error class only tells you the first digit. A neighbor in that class is a different fault, and the fix on this page does not transfer to it.

Return 411 when your handler cannot accept a body whose length is unknown and the request omitted Content-Length. If you can read chunked bodies, do that instead of forcing the client to buffer. Do not use 411 for a body that is merely too large. That is 413.

How to fix HTTP 411

To fix HTTP 411, change the condition that made the server choose Length Required. If you can buffer the body, retry once with Content-Length. If the body is a stream you cannot measure, you cannot satisfy this server. Stop and report that. One retry with a length is appropriate. Retrying without a length is not. If the log line is a different code, leave this page. The mix-up people make with 411 is this one: 413 means the length is known and too big. 400 means the request was malformed in some other way. 411 is specifically the missing length.

  • A proxy stripped Content-Length and the origin answered 411.
  • The client retried with chunked encoding again and looped.
  • A small bug required Content-Length on GET, which has no body.

An access log that only stores 411 is not enough to tell these apart. Keep the method, the path, and a request id. Do not keep the Authorization header or a request body that might be a token. The status explains the outcome. It is not a place to echo secrets back to the client either.

Example response

HTTP 411 Length RequiredHTTP/1.1 411 Length Required
Connection: close

The client resends the same body with Content-Length set to the byte count. Connection: close is common because the previous body may have left the connection in an awkward state. Do not require a length you do not need.

What the client should do

If you can buffer the body, retry once with Content-Length. If the body is a stream you cannot measure, you cannot satisfy this server. Stop and report that.

Do not cache 411. It is about the request framing, not the resource.

One retry with a length is appropriate. Retrying without a length is not.

Codes people confuse with HTTP 411

413 means the length is known and too big. 400 means the request was malformed in some other way. 411 is specifically the missing length.

Frequently asked questions

Does 411 mean the body was invalid?

No. It means the server wants Content-Length before it will read the body.

What should the client change?

Send Content-Length. Do not switch to chunked encoding on the retry.

Should GET ever return 411?

No. GET has no body that needs a length.

How is 413 different?

413 means the server knows the size and refuses it. 411 means the size was not stated.

What should I do first when I see HTTP 411?

Read the status as 411 Length Required specifically. 411 Length Required means the server refuses the request without a Content-Length. Then check the cause that matches the request you sent, starting with: A client used chunked encoding and the origin rejects it.