413 Payload Too Large

Client Error - Request body exceeds server limits

HTTP 413 Payload Too Large

What It Means

The HTTP 413 Payload Too Large status code (formerly "Request Entity Too Large") indicates that the request body is larger than the server is willing or able to process. This is commonly encountered when uploading files that exceed size limits.

Common Causes

  • File uploads: Uploading files larger than allowed
  • API payloads: JSON/XML request bodies exceeding limits
  • Form data: Large form submissions with many fields
  • Base64 data: Embedded images or files in request body

Server Configuration

Increase limits in your web server:

# Nginx
client_max_body_size 100M;

# Apache
LimitRequestBody 104857600

# Node.js (Express)
app.use(express.json({ limit: '100mb' }));

# PHP
upload_max_filesize = 100M
post_max_size = 100M

Solutions for Large Files

  • Chunked uploads: Split large files into smaller parts
  • Streaming uploads: Upload directly to cloud storage (S3, GCS)
  • Compression: Compress files before uploading
  • Presigned URLs: Upload directly to storage, bypassing your server

Retry-After Header

The server may include a Retry-After header indicating when the condition might be resolved:

HTTP/1.1 413 Payload Too Large
Retry-After: 3600
Content-Type: application/json

{
  "error": "File size exceeds maximum allowed (50MB)",
  "max_size_bytes": 52428800
}

Best Practices

  • Validate file sizes on the client before uploading
  • Show clear error messages with the maximum allowed size
  • Consider using resumable uploads for large files
  • Document your size limits in your API documentation

Frequently Asked Questions

What does HTTP 413 Payload Too Large mean?
HTTP 413 Payload Too Large (formerly called 'Request Entity Too Large') means the request body is bigger than the server is willing or able to process. This commonly occurs when uploading files that exceed the configured maximum size in your web server (Nginx, Apache) or application framework.
How do I fix a 413 error in Nginx?
In Nginx, increase the client_max_body_size directive. Add 'client_max_body_size 100M;' in the http, server, or location block of your nginx.conf file. The default is only 1MB, which is too small for most file upload use cases. Restart Nginx after making the change.
What is the difference between 413 and 414?
413 Payload Too Large refers to the request body (POST/PUT data, file uploads) being too big. 414 URI Too Long refers to the URL itself being too long (usually from excessive query string parameters). They address different parts of the HTTP request that can exceed limits.
How can I handle large file uploads without hitting 413?
Use chunked uploads to split files into smaller parts, upload directly to cloud storage (S3, GCS) using presigned URLs to bypass your server entirely, compress files before uploading, or implement resumable uploads with the tus protocol. These approaches avoid the server's body size limits.
Should I increase my server's max body size?
Only increase it to what you actually need. Setting very high limits (like 10GB) can expose your server to denial-of-service attacks where clients send enormous requests. Instead, set a reasonable limit for your use case and use client-side validation to reject oversized files before they are sent.

Monitor your API health

UptimeSignal tracks your endpoints and alerts you to errors.

Start monitoring free →

Related Status Codes

More Resources