413 Request Entity Too Large: raise upload limits in nginx, PHP and more
Uploads fail with 413 when any layer's size limit is hit. The defaults for nginx, Apache, PHP, Node and Cloudflare, and how to raise them safely.
· 3 min read · By the Spot Downtime team
413 Request Entity Too Large (now officially called Content Too Large) means the request body is bigger than the server agreed to accept. It nearly always shows up as a failed file upload. The fix is simple once you find which limit you hit, because a typical request passes through three or four of them.
Every layer has its own limit
| Layer | Setting | Default |
|---|---|---|
| nginx | client_max_body_size | 1 MB |
| Apache | LimitRequestBody | 1 GB (since 2.4.54) |
| PHP | upload_max_filesize | 2 MB |
| PHP | post_max_size | 8 MB |
| Cloudflare | Plan limit | 100 MB on Free and Pro |
| Express (body-parser) | limit | 100 KB for JSON |
The smallest limit in the chain wins. Raising PHP's limit to 100 MB does nothing while nginx in front of it still stops at 1 MB.
Find which layer said no
Look at the error page. nginx shows a bare 413 Request Entity Too Large nginx page; Cloudflare shows its own branded page; PHP often doesn't return 413 at all, it just hands your code an empty upload. Then fix from the outside in.
server response header shows what sits in front of your app: nginx, Apache or a CDN like Cloudflare.Raising the limits
nginx
server {
client_max_body_size 50m; # or inside a single location block
}sudo nginx -t && sudo systemctl reload nginxPHP (including WordPress)
upload_max_filesize = 50M
post_max_size = 55M ; slightly bigger: the form has other fields too
memory_limit = 256MRestart PHP-FPM after the change, and check phpinfo() to confirm the values loaded from the file you edited.
Node.js
app.use(express.json({ limit: "5mb" }));Raise limits per route, not everywhere
If you're a visitor
Compress the file, export the image at a lower resolution, or split the upload. There's nothing to change on your side; the limit is the site's setting.
Get new guides by email
Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.
Keep reading
- HTTP errors · HTTP · Troubleshooting304 Not Modified: what it means and how conditional requests workA 304 is not an error: it means the cached copy is still good. How ETag and Last-Modified revalidation works, why a 304 can go wrong, and how to debug stale content.November 26, 2026 · 7 min read
- HTTP errors · TroubleshootingRandom 502 errors behind a load balancer: the keep-alive timeout mismatchRare, unpredictable 502s with a healthy backend often come from keep-alive timeouts: the app closes idle connections before the proxy does. How to confirm and fix it.November 26, 2026 · 6 min read