Troubleshooting guide · http-status · Published 2026-08-16 · 4 min read
HTTP 413 payload too large error
HTTP 413 means the request body is too big: check nginx and Apache client limits, PHP upload values, proxies and the reading of the error log line.
- ·Who sends the 413
- ·The four sizes
- ·Read the log to find it
What 413 means
HTTP 413 Payload Too Large says the request body (the part after the headers: the uploaded file, the form POST, or the JSON payload) is bigger than the server allows. It is useful because it is precise: the server did not choke on the URL or the method, it rejected the body on size. The text varies ("Payload Too Large", "Request Entity Too Large", "File too large"), and the client's message reflects whichever proxy spoke it.
Who sends the 413
The layer that answers first also names the limit to raise:
| Layer | Typical setting | Symptom |
|---|---|---|
| Web server (nginx) | client_max_body_size | The browser shows the raw limit error from the edge that owns it |
| Web server (Apache) | LimitRequestBody in httpd/php config | The request entity too large page |
| Proxy/CDN/cloud LB | Platform body limit (often 25 MB or 100 MB) | The proxy's branded error page, not Apache's |
| PHP itself | post_max_size + upload_max_filesize | The upload fails mid-request, sometimes a 413, sometimes a 500 |
The media upload article covers the WordPress/PHP size pair; this article is the nginx/Apache/proxy layer that sits in front of PHP.
The four sizes, one chain
A request body passes a chain, and each link has its own limit. A 413 can come from any of them:
- The web server. Nginx:
client_max_body_size 25m;in aserverorlocationblock. Default is 1 MB, so a large file upload fails until it is raised. - The proxy or cloud load balancer. Many CDNs and LBs reject bodies over 25 MB or 100 MB before nginx or Apache sees them, and reply with their own 413.
- Apache.
LimitRequestBody(bytes, default 1 GiB on Linux, often a much lower panel-configured value). cPanel/WHM panels frequently set a 1 MB or 2 MB PHP bound in the handler that mirrors the same failure. - PHP (when the body reaches it):
upload_max_filesizeandpost_max_size, as in the media upload article.
Raise the one the error line names, not all four.
Read the error that names the layer
The same page request yields a different trace per layer:
curl -i -X POST https://example.com/api/upload --data-binary @big.bin
HTTP/1.1 413 Payload Too Large
Then look in the log beside it:
- Nginx:
client intended to send too large bodyinnginx/error.log - Apache:
Request entity is too largein the Apache access or error log - Proxy: the edge vendor's error view, e.g. a CDN "413" with its own body
The error log reading article explains mapping a line to the layer that logged it.
The fix order
- Confirm the true size.
ls -lhthe file, and check the form/API sends what you think: a mobile library that re-encodes can double the body. - Raise the named limit, in the named file. Nginx:
location /uploads {
client_max_body_size 30m;
}
Then nginx -s reload (the setting is read on reload; no restart needed).
- Check the proxy ahead of the origin. If the site is behind a CDN or cloud LB, its own limit (typically lower than the origin's) returns the 413 before your server even sees the request. Raise it there, or pre-size objects so uploads go to a URL that bypasses the body limit (S3 presigned uploads, or a dedicated upload host).
- Look for a cascade. A root cause one layer down: nginx serves fine over
proxy_passbut the LB in front caps at 10 MB. A 413 from the first hop hides a healthy origin. - If the upload is genuine production traffic (tens of MB files), the honest fix is out-of-band: upload to object storage with a presigned URL and reference it, keeping the web server body limit at a sane guardrail. The performance CDN article covers why that also wins on load.
Prevention
- Set
client_max_body_sizedeliberately (default 1 MB is the silent cause of most "file too large" reports). - Keep upload limits in four places aligned: web server, proxy, PHP, and the app's own validator.
- Check front-end validators mirror the server: an app that allows 50 MB while nginx allows 1 MB fails loudly for nobody.
- After a host migration, compare the old
nginx.conf/.htaccesslimits with the new ones before announcing the move.
When a large body also returns a bad request or times out instead of 413, the cause is the request itself or a proxy that reads it too slowly; the 400 bad request and 504 gateway timeouts references are the adjacent articles.