Length Required
4xx Client Error
Last updated:
The server refuses to accept the request without a Content-Length header.
Description
Rare — most modern servers accept chunked encoding as an alternative. Some proxies enforce Content-Length for security reasons.
When to use
Return 411 if your infrastructure requires Content-Length for anti-abuse reasons.
Specification
RFC 9110 §15.5.12
Examples
HTTP response
HTTP/1.1 411 Length Required
Content-Type: application/json
{"error":"Length Required"}Node.js (Express)
res.status(411).json({ error: "Length Required" });Go (net/http)
w.WriteHeader(http.Status411)
Python (Flask)
return jsonify({"error": "Length Required"}), 411All 4xx codes
400 Bad Request401 Unauthorized403 Forbidden404 Not Found405 Method Not Allowed406 Not Acceptable408 Request Timeout409 Conflict410 Gone411 Length Required412 Precondition Failed413 Payload Too Large414 URI Too Long415 Unsupported Media Type418 I'm a teapot422 Unprocessable Entity425 Too Early428 Precondition Required429 Too Many Requests431 Request Header Fields Too Large451 Unavailable For Legal Reasons