411

HTTP 411 Length Required

4xx Client Error

4xx Client Error RFC 7231, Section 6.5.10

What is HTTP 411 Length Required?

The 411 (Length Required) status code indicates that the server refuses to accept the request without a defined Content-Length header. The client must include a valid Content-Length header field containing the length of the message body.

Common Use Cases

  • Upload endpoints requiring Content-Length
  • APIs that validate request body size before processing

Usage Example

When your API processes file uploads, require a Content-Length header to know the file size before reading the body. If the header is missing, return 411 Length Required. This allows the server to reject oversized files early without reading the entire payload.

// Laravel middleware - requiring Content-Length
if (! $request->headers->has('Content-Length') && $request->getContent()) {
    return response()->json([
        'error' => 'Content-Length header is required',
    ], 411);
}
Last updated: 21 Jun 2026