411
HTTPERRORNotable4xx Client ErrorHIGH confidence

Length Required

Production Risk

Low. It is a clear protocol requirement violation. Most modern HTTP client libraries handle setting the Content-Length header automatically.

What this means

The server rejected the request because the Content-Length header field is not defined and the server requires it. The client may repeat the request if it adds a valid Content-Length header field containing the length of the message body.

Why it happens
  1. 1A client sends a POST, PUT, or PATCH request with a body but omits the 'Content-Length' header.
  2. 2A server is configured to require 'Content-Length' for security or resource allocation reasons.
  3. 3Some proxies or firewalls might strip this header, causing the error.
How to reproduce

A client attempts to POST data to a server without specifying the size of the request body.

trigger — this will error
trigger — this will error
POST /api/data HTTP/1.1
Host: example.com
Content-Type: application/json

{ "key": "value" }

expected output

HTTP/1.1 411 Length Required

Fix

Add a Content-Length Header

WHEN Sending a request with a body.

Add a Content-Length Header
POST /api/data HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 17

{ "key": "value" }

Why this works

Client-Side Correction

Version notes

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All HTTP errors