413

Payload Too Large

The request body exceeds the maximum size the server is willing to process.

Quick Definition

The server is refusing to process the request because the request payload (body) is larger than the server is willing or able to handle. Previously known as "413 Request Entity Too Large." The server may close the connection to prevent the client from continuing to send data.

When It Occurs

A 413 error occurs when you send a request body that exceeds the server's configured maximum size. This is most commonly encountered during file uploads, large JSON/XML payload submissions, or when posting form data with many fields or large values.

The limit can be enforced at multiple layers: the web server (Nginx, Apache), the application framework (Express, Django), the CDN (Cloudflare), or even the hosting platform (AWS Lambda, Vercel). Each layer may have its own independent limit.

Common Causes

  • File upload exceeds server limit - Uploading a file larger than the configured maximum (often 1MB-10MB by default)
  • Large JSON/XML request body - API requests with very large payloads exceeding body parser limits
  • Base64-encoded files in request body - Encoding files as base64 increases size by ~33%, pushing past limits
  • Multiple file upload exceeding total limit - Uploading several files at once that collectively exceed the limit
  • CDN/proxy enforcing stricter limits - Cloudflare or reverse proxy rejecting before the request reaches your server
  • Default server configuration unchanged - Using default limits that are too low for your use case

Platform-Specific Notes:

Nginx Default is 1MB. Increase with client_max_body_size 100M; in http, server, or location block. Reload after changes.

Apache Use LimitRequestBody 104857600 (100MB in bytes) in httpd.conf or .htaccess. For PHP: set upload_max_filesize and post_max_size in php.ini.

Cloudflare Free plan: 100MB max upload. Pro: 100MB. Business: 200MB. Enterprise: 500MB. Cannot be exceeded regardless of origin server settings.

Node.js Express body-parser defaults to 100KB for JSON. Increase with app.use(express.json({ limit: '50mb' })).

🛠 How to Fix

  1. Check current size limits - Identify which layer is rejecting the request (web server, app framework, CDN)
  2. Increase web server limits - Set client_max_body_size (Nginx) or LimitRequestBody (Apache) to a higher value
  3. Update application body parser limits - Increase express.json({ limit }) or equivalent framework setting
  4. Check CDN/proxy limits - Verify Cloudflare, AWS ALB, or other proxy limits match your needs
  5. Compress files before uploading - Use gzip or client-side compression to reduce payload size
  6. Implement chunked uploads - Break large files into smaller chunks and reassemble on the server

💻 HTTP Example

# Client tries to upload a 50MB file (server limit: 10MB)
POST /api/upload HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----abc123
Content-Length: 52428800

# Server Response
HTTP/1.1 413 Payload Too Large
Content-Type: application/json
Connection: close
Retry-After: 3600

{
  "error": "Payload Too Large",
  "message": "Request body exceeds the 10MB limit",
  "max_size": "10MB",
  "your_size": "50MB",
  "statusCode": 413
}

Frequently Asked Questions

How do I increase the upload size limit in Nginx? +
Add or increase the client_max_body_size directive in your Nginx configuration. For example, client_max_body_size 100M; allows uploads up to 100 megabytes. You can place this in the http block (applies globally), server block (applies to one domain), or location block (applies to specific paths). After changing the config, reload Nginx with sudo nginx -s reload.
What is the default upload size limit? +
Default limits vary by platform: Nginx defaults to 1MB (client_max_body_size). Apache has no hard default, but PHP defaults to 2MB (upload_max_filesize) and 8MB (post_max_size). Express/Node.js body-parser defaults to 100KB for JSON bodies. Cloudflare limits uploads to 100MB on free and Pro plans. Always check all layers in your stack, as the strictest limit wins.

Scan Your Site for HTTP Errors

Detect upload failures, misconfigured limits, and server errors across your web infrastructure.

Start Free Scan