411

Length Required

Overview

411 Length Required means the server needs to know the size of the request body up front, but no Content-Length header was supplied, so it refuses to process the request. It happens when the server does not support chunked transfer encoding or policy requires an explicit body length.

Most HTTP client libraries add Content-Length automatically when they send a body, so this error usually appears in low-level socket code or streaming uploads.

When it happens

Request / Response example

Request
POST /upload HTTP/1.1
Host: api.example.com
Content-Type: application/octet-stream

<binary body with no Content-Length>
Response
HTTP/1.1 411 Length Required
Content-Type: text/plain
Content-Length: 33

Content-Length header is required.

In code

# Let curl compute and send Content-Length from a file
curl -X POST --data-binary @payload.bin \
  -H 'Content-Type: application/octet-stream' \
  https://api.example.com/upload
# Reject chunked requests where a length is mandatory
if ($http_content_length = "") {
  return 411;
}

Common causes

How to fix

Notes

Related status codes

Related headers

Specification