Error Codes Wiki

HTTP 411 Length Required — Missing Content-Length Header

Warning4xx client error

Overview

HTTP 411 Length Required means the server refuses the request because the Content-Length header is missing and the server requires it.

Key Details

  • Server requires the Content-Length header but the client did not send it
  • Common with POST and PUT requests that have a request body
  • Some servers and proxies require Content-Length for security and resource allocation
  • Chunked transfer encoding (Transfer-Encoding: chunked) may not be accepted
  • Load balancers and WAFs frequently enforce Content-Length requirements

Common Causes

  • HTTP client not setting Content-Length header on POST/PUT requests
  • Using chunked transfer encoding against a server that does not support it
  • Proxy or WAF stripping the Content-Length header from requests
  • Streaming request body without pre-calculating total size

Steps

  1. 1Add Content-Length header to your request matching the body size in bytes
  2. 2In curl, use -H 'Content-Length: N' or let curl calculate it automatically with -d
  3. 3If using chunked encoding, switch to buffered body with explicit Content-Length
  4. 4Check if a proxy or CDN is modifying request headers in transit
  5. 5For large uploads, check if the server supports chunked encoding or requires Content-Length

Tags

http411length-requiredcontent-lengthheader

More in 4xx Client Error

Frequently Asked Questions

Servers use it to allocate memory, enforce size limits, and detect incomplete transmissions.