Skip to content

Troubleshooting guide

413 Request Entity Too Large: how to raise the limit safely

A 413 means the request body was bigger than something along the path allows. There are often several limits in a row, and the smallest one wins.

3 min read10 sectionsUpdated

On this page

Key points

  • Every layer has its own limit: CDN, ingress, web server, runtime and framework.
  • Nginx defaults to 1 MB, which many upload forms exceed.
  • Raise it only on the route that needs it, not on the whole site.
  • Large files belong in object storage via direct upload.

What 413 means

The server refuses to read a request body over its configured size. Fixing the first limit often reveals the next, so list every hop before changing anything: CDN, load balancer, ingress controller, web server, language runtime, framework.

Where the limits live

  • Nginx: client_max_body_size, default 1 MB.
  • Kubernetes ingress-nginx: the nginx.ingress.kubernetes.io/proxy-body-size annotation.
  • Apache: LimitRequestBody.
  • PHP: upload_max_filesize and post_max_size, and both must be large enough.
  • Node.js: body parser limits, such as Express's default of 100 KB for JSON.
  • CDN: Cloudflare caps upload size by plan, 100 MB on Free and Pro.

Find the layer that refused

The error page format identifies it. Test around the limit with a generated file and compare results when you go through the CDN and directly to the origin.

bash
# Create a 5 MB test file and post it
head -c 5242880 /dev/urandom > /tmp/5mb.bin
curl -si -X POST --data-binary @/tmp/5mb.bin https://example.com/upload | head -8

# Effective Nginx limit, including every included file
sudo nginx -T 2>/dev/null | grep client_max_body_size

# PHP limits
php -i | grep -E 'upload_max_filesize|post_max_size'

Fixes

Scope the increase to the upload route:

location /upload { client_max_body_size 50m; proxy_pass http://app; }

Then reload with nginx -s reload after nginx -t. Set the same limit in the ingress annotation and in the application so each layer agrees. For very large files, stop passing them through your servers: issue a presigned URL and let the browser upload to object storage directly. Validate size on the client as well, so the user gets a clear message before waiting for an upload to fail.

Catch it automatically

A rising 413 count usually means a client started sending more than before, such as a phone camera with larger photos. Track it per route in APM and include the observed Content-Length in logs. Avoid setting limits to unlimited, as a huge body can exhaust disk or memory and turn one upload into an outage.

Frequently asked questions

What is the default Nginx upload limit?

client_max_body_size defaults to 1 MB. Requests with larger bodies receive a 413.

I raised the limit, why do I still get 413?

Another layer has a smaller limit. Check the CDN, the ingress controller, the application framework and the language runtime in turn.

Should I set client_max_body_size 0?

That disables the check, which removes a basic protection against disk and memory exhaustion. Prefer an explicit limit on the routes that need it.

Check it now, free

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.