HTTP 411 Length Required — Missing Content-Length Header
About HTTP 411 Length Required
HTTP 411 Length Required means the server refuses the request because the Content-Length header is missing and the server requires it. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: 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. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: 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. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Add Content-Length header to your request matching the body size in bytes. In curl, use -H 'Content-Length: N' or let curl calculate it automatically with -d. If using chunked encoding, switch to buffered body with explicit Content-Length. Check if a proxy or CDN is modifying request headers in transit. For large uploads, check if the server supports chunked encoding or requires Content-Length. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Why does my server require Content-Length?
Servers use it to allocate memory, enforce size limits, and detect incomplete transmissions.
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
- 1Add Content-Length header to your request matching the body size in bytes
- 2In curl, use -H 'Content-Length: N' or let curl calculate it automatically with -d
- 3If using chunked encoding, switch to buffered body with explicit Content-Length
- 4Check if a proxy or CDN is modifying request headers in transit
- 5For large uploads, check if the server supports chunked encoding or requires Content-Length