HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

411 Length Required

Fault: Client
TL;DR

The server will not accept the request without a defined Content-Length so it knows how much body to read.

The server refuses the request because it lacks a Content-Length header.

What HTTP 411 Length Required Means

The server refuses the request because it lacks a Content-Length header.

The server will not accept the request without a defined Content-Length so it knows how much body to read.

Common Causes

How to Fix It (For Visitors)

How to Fix It (For Developers/Admins)

Returning a 411 Length Required (Code Examples)

If you build APIs or web apps, here is how to send an HTTP 411 response and how to test for it:

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(411).json({ error: 'Length Required' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Length Required'), 411

PHP

<?php
http_response_code(411);
header('Content-Type: application/json');
echo json_encode(['error' => 'Length Required']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 411 Length Required

Frequently Asked Questions

What does HTTP 411 Length Required mean?

The server will not accept the request without a defined Content-Length so it knows how much body to read. In short: The server refuses the request because it lacks a Content-Length header.

Is 411 Length Required a client or server error?

411 is a 4xx client-error code, so the request itself needs to change. The server is running normally and is rejecting the request as it was sent by the browser, app, or API client.

How do I fix a 411 Length Required error?

Set the Content-Length header on the request. Buffer the body so its length is known before sending. Enable chunked transfer support on the server if appropriate.

Official Specification

The 411 Length Required status code is defined in RFC 9110 Section 15.5.12.

View the IANA HTTP Status Code Registry →