411 Length Required

HTTP Status CodesClient (4xx)rarerStatus Code: 411Last updated: todayTested on:Google ChromeNode.js v20 LTSJune 2026

The server refuses to accept the request without a defined Content-Length header.

411 Length Required Quick Fix⏱️ Est. Fix Time: 3 minutes

Usually happens because:

  • Client sending POST or PUT
  • Server security rules rejecting chunked

🔍 Quick Checklist:

Meaning

The HTTP 411 Length Required client error status code indicates that the server refuses to accept the request without a defined Content-Length header field in the client request.

Root Causes

  • Client sending POST or PUT requests carrying body payloads but omitting the Content-Length header field.
  • Server security rules rejecting chunked transfer-encoding requests.
CauseFrequency
Client sending POST or PUT⭐⭐⭐⭐⭐
Server security rules rejecting chunked⭐⭐⭐⭐

Common Mistakes

  • Sending empty POST requests without setting Content-Length to 0.
  • Assuming chunked transfer-encoding is supported by all legacy proxy gateways.

How to Fix

1Ensure client library requests declare Content-Length headers explicitly.
2Configure server settings to support chunked encoding filters.

Framework-Specific Examples

Express middleware rejecting POST/PUT routes lacking Content-Length.

Express Example
app.use((req, res, next) => {
  if (['POST', 'PUT'].includes(req.method) && !req.headers['content-length']) {
    return res.status(411).send('Length Required');
  }
  next();
});

Server Configuration Examples

Nginx enforces Content-Length validations automatically.

Nginx Config
# Nginx returns 411 immediately if content-length is missing on write methods

Prevention

  • Verify client fetch libraries calculate content lengths dynamically.

Frequently Asked Questions (FAQ)

Q: Why does a server require a Content-Length header?

It allows the server to allocate request buffers correctly and protect itself from Denial of Service (DoS) attacks where clients stream bytes indefinitely.

Q: Can I use 'Transfer-Encoding: chunked' instead of Content-Length?

Yes. If chunked encoding is used, Content-Length is not required. However, if the server refuses chunked encoding, it will return 411.

Q: Does 411 apply to GET requests?

No. GET requests have no payload body and thus do not require a Content-Length header.

Q: How do client libraries solve 411 errors?

Most modern client libraries (like Axios or Fetch) calculate the payload byte size and append the Content-Length header automatically.

Still having this problem?

Didn't solve your problem?

SuggestRequest Error