413

HTTP 413 Content Too Large

4xx Client Error

4xx Client Error RFC 7231, Section 6.5.11

What is HTTP 413 Content Too Large?

The 413 (Content Too Large) status code indicates that the request body is larger than the server is willing or able to process. The server may close the connection or include a Retry-After header. This was originally called "Request Entity Too Large" and is often seen during file uploads that exceed server limits.

Common Use Cases

  • Uploading files that exceed server size limits
  • API request body size limits
  • Preventing denial-of-service through large payloads

Usage Example

When building a file upload API, configure a maximum file size (e.g., 10MB) and return 413 Content Too Large if the client exceeds it. Include the maximum allowed size in the response so the client can validate uploads before sending them.

// Laravel - validation with max file size
$request->validate([
    'file' => 'required|file|max:10240', // 10MB
]);

// Manual 413 check
if ($request->file('file')->getSize() > 10 * 1024 * 1024) {
    return response()->json([
        'error' => 'File too large',
        'max_size_mb' => 10,
    ], 413);
}

Common Mistakes

⚠️

Mistake: Returning 400 instead of 413 for oversized payloads

Fix: Use 413 Content Too Large specifically when the payload exceeds size limits. It is more descriptive than the generic 400 and helps clients understand the specific issue.

⚠️

Mistake: Not including the maximum allowed size in the response

Fix: Always include the maximum allowed payload size in the 413 response so clients can adjust their requests accordingly without guessing.

Last updated: 21 Jun 2026