Skip to content
HTTP 411 Length Required — What It Means & How to Fix

HTTP 411 Length Required — What It Means & How to Fix

DodaTech Updated Jun 20, 2026 5 min read

HTTP 411 Length Required means the server refuses to accept the request without a defined Content-Length header — required for POST/PUT with body.

What It Means

The HTTP 411 Length Required status code is the server’s way of saying: “I need to know the size of the request body before I can process it.” The server requires a Content-Length header in the request, and the client did not provide one. This is typically enforced for requests with a body — POST, PUT, and PATCH — where the server needs to allocate resources or validate the payload size before processing.

The Content-Length header is a critical piece of HTTP metadata. It tells the server exactly how many bytes to expect in the request body. Without it, the server either has to read until the connection closes (which prevents connection reuse) or use chunked transfer encoding. Some servers and firewalls reject requests that have a body but no Content-Length as a security measure against HTTP request smuggling or slow-loris attacks.

This is different from a missing body — 411 means the server knows there is a body (detected by the method or other headers) but cannot determine its size. The fix is almost always to add the correct Content-Length header to the request.

When It’s Sent

  • Missing Content-Length on POST — a POST request with a body but no Content-Length header
  • Strict server configuration — a security-hardened server that requires Content-Length for all requests
  • Load balancer or proxy enforcement — an intermediate proxy that validates request headers before forwarding
  • Firewall or WAF rules — a Web Application Firewall that blocks requests without Content-Length
  • Chunked encoding not supported — the server does not support Transfer-Encoding: chunked and requires fixed-length bodies

Real Example

curl -v -X POST \
  -H "Content-Type: application/json" \
  --data-raw '{"name":"Test"}' \
  -H "Transfer-Encoding: chunked" \
  https://api.example.com/items

If the server does not support chunked encoding:

> POST /items HTTP/1.1
> Host: api.example.com
> Content-Type: application/json
> Transfer-Encoding: chunked
>
< HTTP/1.1 411 Length Required
< Content-Type: text/html
< Content-Length: 168
<
<html>
<head><title>411 Length Required</title></head>
<body>
<h1>Length Required</h1>
<p>A Content-Length header is required for this request.</p>
</body>
</html>

Adding the Content-Length header fixes it:

curl -v -X POST \
  -H "Content-Type: application/json" \
  -H "Content-Length: 16" \
  -d '{"name":"Test"}' \
  https://api.example.com/items

How to Debug

Client-Side

  1. Add Content-Length header — calculate the body size in bytes and set it explicitly
  2. Let your HTTP library handle it — most libraries (curl, Python requests, fetch) set Content-Length automatically
  3. Avoid chunked encoding — use a fixed-length body instead of Transfer-Encoding: chunked where possible
  4. Check for middleware stripping headers — some proxy software may remove Content-Length
  5. Verify the request has a body — a GET or DELETE request doesn’t need Content-Length unless there’s a body

Server-Side

  1. Check server configuration — review web server settings that enforce Content-Length
  2. Verify middleware and security tools — WAF rules, rate limiters, and request validators may require Content-Length
  3. Support chunked encoding — if clients send chunked requests, ensure the server can handle them
  4. Review error logs — look for the specific paths and methods triggering the 411
  5. Test with and without Content-Length — isolate whether the issue is on the client or server side

curl

# See the error (no Content-Length sent manually, but curl adds it by default for -d)
curl -v -X POST -H "Content-Type: application/json" \
  -H "Transfer-Encoding: chunked" \
  -d '{"test":"data"}' https://example.com/api

# Force curl to omit Content-Length by using -T with a file
echo '{"test":"data"}' | curl -v -X POST -H "Content-Type: application/json" \
  -T - https://example.com/api

Postman

Postman automatically includes Content-Length for requests with a body. To test a missing header, go to the Headers tab and remove Content-Length (Postman adds it automatically for body requests — you may need to use the bulk edit mode or a manual HTTP client to simulate the missing header).

Common Causes

ScenarioWhat HappensWhy It Matters
Body without Content-LengthServer cannot determine request sizeRequest is rejected before processing
Chunked encoding unsupportedServer requires fixed-length bodiesMust switch to Content-Length-based requests
Reverse proxy stripping headersProxy removes Content-LengthCheck proxy configuration to preserve headers
WAF enforcementFirewall requires Content-Length for securityAdd the header or adjust WAF rules
HTTP/1.0 clientOlder clients may omit Content-LengthUpgrade client or configure server to accept chunked

FAQ

Do I always need to include Content-Length?
Not always. For GET, HEAD, and DELETE requests that have no body, Content-Length is typically not required. For POST, PUT, and PATCH with a body, most HTTP clients add it automatically. However, some security-hardened servers and proxies require it for all requests — including those without a body (set to Content-Length: 0).
What is the difference between Content-Length and Transfer-Encoding: chunked?
Content-Length specifies the exact size of the body in bytes. Transfer-Encoding: chunked sends the body in chunks, each preceded by its size, and terminates with a zero-length chunk. Chunked encoding is used when the body size is not known in advance (e.g., streaming data). A server that returns 411 typically does not support chunked encoding and requires a fixed Content-Length.
How do I calculate Content-Length for binary data?
Count the bytes of the request body, not the characters. For JSON or text, the byte count may differ from the character count if non-ASCII characters are used. In curl, the Content-Length is automatically calculated. In code, use len(body_bytes) in Python, Buffer.byteLength(body) in Node.js, or body.length in Go — always on the encoded (UTF-8) byte representation.

Related Codes

  • HTTP 400 Bad Request — general client error when headers are malformed
  • HTTP 413 Payload Too Large — the body exceeds the server’s size limit
  • HTTP 415 Unsupported Media Type — the Content-Type is not supported
  • HTTP 500 Internal Server Error — server error that may occur if Content-Length processing fails

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro