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