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.

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:

LayerTypical settingSymptom
Web server (nginx)client_max_body_sizeThe browser shows the raw limit error from the edge that owns it
Web server (Apache)LimitRequestBody in httpd/php configThe request entity too large page
Proxy/CDN/cloud LBPlatform body limit (often 25 MB or 100 MB)The proxy's branded error page, not Apache's
PHP itselfpost_max_size + upload_max_filesizeThe 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:

  1. The web server. Nginx: client_max_body_size 25m; in a server or location block. Default is 1 MB, so a large file upload fails until it is raised.
  2. 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.
  3. 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.
  4. PHP (when the body reaches it): upload_max_filesize and post_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:

The error log reading article explains mapping a line to the layer that logged it.

The fix order

  1. Confirm the true size. ls -lh the file, and check the form/API sends what you think: a mobile library that re-encodes can double the body.
  2. 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).

  1. 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).
  2. Look for a cascade. A root cause one layer down: nginx serves fine over proxy_pass but the LB in front caps at 10 MB. A 413 from the first hop hides a healthy origin.
  3. 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

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.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services