Nginx 413: Request Entity Too Large

An upload fails with '413 Request Entity Too Large'. Nginx has a size limit on request bodies, and your file blew past it. Here's the one directive to change — and why the app never even saw the request.

BytExplorer 4 min read July 1, 2026

A file upload dies and the browser shows:

413 Request Entity Too Large

This one is entirely Nginx's doing, and your application never even got the request. Nginx caps the size of a request body with a directive called client_max_body_size — default 1 MB. Anything bigger is rejected at the door with a 413, before it's ever proxied to your app. So no amount of changing app settings will help.

Confirm it in the log

tail -f /var/log/nginx/error.log
# client intended to send too large body: 5242880 bytes

That line names the exact size that tripped the limit.

The fix: raise client_max_body_size

Set it to a ceiling that fits your largest legitimate upload. You can place it in the http, server, or a specific location block — narrowest scope is best:

server {
    # allow uploads up to 50 MB on this site
    client_max_body_size 50m;

    location /upload {
        proxy_pass http://127.0.0.1:8000;
    }
}

Then test and reload — never skip the test:

nginx -t && systemctl reload nginx    # -t catches typos before they take the site down

Set the limit to a real number, not "as high as possible". client_max_body_size 0 disables the check entirely, which invites someone to exhaust your disk or memory with a giant upload. Pick a value slightly above your biggest genuine file.

Don't forget the app's own limit

Nginx is only the first gate. Your framework often has its own body-size cap (Django's DATA_UPLOAD_MAX_MEMORY_SIZE, PHP's upload_max_filesize). If uploads still fail after fixing Nginx, raise the matching limit in the app too.

The checklist

  1. 413 = Nginx rejected the body before your app saw it.
  2. Confirm with "too large body" in the error log.
  3. Set client_max_body_size to a sane ceiling in the right block.
  4. nginx -t && systemctl reload nginx.
  5. Raise the framework's upload limit to match.
Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Troubleshooting