Back to blog
Linux & Servers Published November 12, 2026

Fix: nginx 413 Request Entity Too Large (client_max_body_size)

Automate WhatsApp Alerts
Start Free ➔
413 Request Entity Too Large
nginx

And in the Nginx error log:

2026/11/12 10:15:32 [error] 1234#1234: *88 client intended to send too large body: 5242880 bytes, client: 203.0.113.7, server: example.com, request: "POST /upload HTTP/1.1", host: "example.com"

Quick fix: Nginx accepts request bodies up to 1 MB by default. Raise the limit and reload:

server {
    server_name example.com;
    client_max_body_size 50M;
    # ...
}
sudo nginx -t && sudo systemctl reload nginx

The client_max_body_size directive sets the largest request body Nginx will accept, which for uploads is roughly the file size. Anything bigger is rejected with 413 before it reaches your app. Setting it to 0 turns the check off completely, which is rarely a good idea on a public server.


1. Put the directive in the right block

client_max_body_size can go in the http, server or location block. The most specific one wins:

http {
    client_max_body_size 10M;          # default for every site

    server {
        server_name example.com;
        client_max_body_size 20M;      # overrides http for this site

        location /upload {
            client_max_body_size 200M; # overrides server for this path only
        }
    }
}

The most common reason a change "does nothing" is that it went into the wrong server block. A site usually has two: one on port 80 that redirects, and one on port 443 that serves the requests. The limit must be in the 443 block (or in http).

Check the value Nginx is really using across all included files:

sudo nginx -T 2>/dev/null | grep -n client_max_body_size

Also remember to reload after editing. Until then, Nginx keeps using the old configuration.


2. Find out which layer sent the 413

The same status code can come from several places. The response body and headers tell you which one:

curl -s -o /dev/null -D - -X POST --data-binary @bigfile.zip https://example.com/upload
You seeIt came fromFix
HTML page with nginx at the bottom, Server: nginxNginxSection 1
Server: cloudflare, Cloudflare error pageCloudflareSection 5
JSON or text such as PayloadTooLargeError: request entity too largeYour Node.js appSection 4
No 413, but the upload fails or WordPress shows an errorPHP limitsSection 3

3. PHP and WordPress limits

After fixing Nginx, PHP has its own two limits. They don't return 413: the upload just fails, or WordPress shows "The uploaded file exceeds the upload_max_filesize directive in php.ini".

Find the active php.ini for PHP-FPM:

php-fpm8.3 -i | grep -E 'Loaded Configuration File|upload_max_filesize|post_max_size'

Set both values, with post_max_size at least as large as upload_max_filesize:

upload_max_filesize = 50M
post_max_size = 55M

Then restart PHP-FPM:

sudo systemctl restart php8.3-fpm

Use the same size (or a little more) for client_max_body_size in Nginx, so the three limits agree.


4. Node.js and other app servers

If the 413 response is JSON or plain text instead of the Nginx page, your app rejected the body. In Express, the default JSON body limit is 100 KB:

app.use(express.json({ limit: '10mb' }));
app.use(express.urlencoded({ limit: '10mb', extended: true }));

For file uploads handled by a library such as Multer, set its limits.fileSize option as well. Other frameworks have the same kind of setting, for example DATA_UPLOAD_MAX_MEMORY_SIZE in Django.


5. Kubernetes ingress and Cloudflare

ingress-nginx sets its own limit of 1 MB per ingress. Changing a client_max_body_size in your app's container won't help; add the annotation to the Ingress instead:

metadata:
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "50m"

Cloudflare limits the request body by plan: 100 MB on Free and Pro, 200 MB on Business, and 500 MB by default on Enterprise. Bigger uploads get a 413 from Cloudflare before they reach your server. For larger files, upload directly to object storage (for example with presigned URLs) or use a hostname that isn't proxied through Cloudflare.


6. Large uploads that still fail after the 413 is gone

Once the size limit is fixed, big uploads over slow connections can hit timeouts instead. If uploads stop with 408 or 504 errors, look at:

  • client_body_timeout (default 60 seconds between two reads from the client)
  • proxy_read_timeout and proxy_send_timeout when Nginx passes the upload to a backend
  • proxy_request_buffering off; if you want Nginx to stream the upload to the backend instead of saving it to disk first

7. Monitoring after config changes

A 413 only affects large uploads, so an uptime check on your homepage won't notice it. Watch the Nginx error log for client intended to send too large body to see how often users hit the limit.

What an uptime monitor does catch is the bigger risk while editing Nginx: a config change or reload that takes the whole site down. With Pingzo, an HTTP monitor checks your site every 1 to 15 minutes depending on your plan, opens an incident when 3 of the last 5 checks fail, and sends alerts to WhatsApp, Slack, Telegram, Discord or email. See how to monitor an Nginx web server or how to monitor WordPress.


Related guides

Zero-Code Uptime Alerts

Stop Finding Out About Outages from Angry Users

Get instant WhatsApp & Discord alerts the second your API, website, or server goes down. Setup in 30 seconds, with checks as often as every minute.

WhatsApp & Discord 60-Second Checks Free Forever Plan
Try Pingzo Free

Know before your users do

Connect official WhatsApp notification channels, Discord webhooks, Telegram bots, and public status pages. Start in 30 seconds.

Create Free Monitor