411 Length Required

A Content-Length header is required.

When to use it

Uploads without a declared size.

Common causes and fixes

The server refuses a request that has a body but no Content-Length header. It happens when a client streams with Transfer-Encoding: chunked to a server or proxy that rejects chunked uploads, or sends a POST with no body and no length at all. Google Cloud Storage and some older servers famously require Content-Length: 0 on empty POST requests.

Fix it on the client: buffer the body so the library can set the length, or set the header yourself. curl -d sets Content-Length automatically, but curl -X POST without data sends none, so add -H Content-Length:0. HTTP/2 and HTTP/3 frames mark the end of the body, so the problem is specific to HTTP/1.1. nginx has accepted chunked request bodies since version 1.3.9.

Client error (4xx)

4xx codes are client errors: the request itself is wrong, unauthorised or points at something that isn’t there. Retrying the same request won’t help.

What it looks like

HTTP/1.1 411 Length Required

How to send it

Node.js / Expressres.status(411).end()
Python / Flaskreturn '', 411
nginxreturn 411;

How to check it

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/

Open HTTP Status Codes