HTTP 413 Content Too Large (Request Entity Too Large)
The request body is bigger than the server is willing to accept — usually a file upload over the configured limit.
Meaning
Every layer between the client and your code has its own maximum body size: CDN, load balancer, web server and language runtime. A 413 comes from whichever layer has the smallest limit. Nginx’s default client_max_body_size is only 1 MB.
Common causes
- Nginx
client_max_body_size(default 1m) too small - PHP
upload_max_filesize/post_max_sizelimits - Apache
LimitRequestBody - Framework body-parser limits (Express
json({ limit })default 100kb) - CDN/load balancer limits (Cloudflare Free: 100 MB, API gateways often 10 MB)
⚡ Quick fix
- Raise
client_max_body_sizein Nginx and reload - Raise
upload_max_filesizeandpost_max_sizein php.ini (post ≥ upload) - Raise the framework body-parser limit
- For very large files, upload directly to object storage with pre-signed URLs
Detailed fix by platform
Nginx
- In
http,serverorlocation:nginxclient_max_body_size 50M; - Run
sudo nginx -t && sudo systemctl reload nginx.
PHP
- php.ini (or .user.ini on shared hosting):ini
upload_max_filesize = 50M post_max_size = 55M memory_limit = 256M - Restart PHP-FPM. Note: when PHP’s limit is exceeded,
$_POSTand$_FILESare silently empty rather than a 413.
Node.js
- Express:javascript
app.use(express.json({ limit: '10mb' })); app.use(express.urlencoded({ extended: true, limit: '10mb' }));
Apache
- Set
LimitRequestBody 52428800(bytes) in the vhost or .htaccess.
How to diagnose
- Size — How large is the request body?
- Response origin — Which layer answered — check the Server header and HTML body of the 413
- Limits — CDN → load balancer → web server → runtime → framework
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026