Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

411 Length Required

Server refuses request because Content-Length header is missing or zero.

When you see this status

  • Client sends POST/PUT without Content-Length header
  • Client sends request with Content-Length: 0
  • Chunked transfer encoding is not supported

Common causes

  • Missing Content-Length header in request
  • Client incorrectly assumes server supports chunked encoding
  • Misconfigured HTTP client libraries

How to debug it

  1. Verify request includes Content-Length header
  2. Check if server supports chunked transfer encoding
  3. Inspect client code for header omission
  4. Test with curl: curl -v -H 'Content-Length: 0' http://example.com

Return this code in your framework

Express (Node.js)
res.status(411).send('Length Required');
FastAPI (Python)
@app.post('/')
def root(request: Request):
    return Response(status_code=411, content='Length Required')
NestJS
@Get()
getData(@Res() res: Response) {
  res.status(411).send('Length Required');
}
Go (net/http)
w.WriteHeader(http.StatusLengthRequired)
w.Write([]byte("Length Required"))

About HTTP 411

HTTP status code 411 Length Required is part of the 4xx Client Error family. Server refuses request because Content-Length header is missing or zero. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Why does the server require Content-Length?

Servers need Content-Length to determine request body size for processing and security checks. Without it, the server cannot safely parse the request.

Can I use chunked transfer encoding instead?

Yes, if the server supports it. Use Transfer-Encoding: chunked. Not all servers support this, especially legacy systems.

How do I fix this in curl?

Add -H 'Content-Length: <size>' where <size> is the byte count of your request body. Omit body for zero-length requests.