413
Nginx 413 Request Entity Too Large: upload size fix
Short answer
413 means the request body exceeded client_max_body_size (default only 1 MB). Raise it in http, server or location; for PHP also raise upload_max_filesize and post_max_size.
Most common cause: client_max_body_size not set; default 1m.
Try this first: Raise the limit
server {
client_max_body_size 100m; # 0 disables the limit (not recommended)
}Last verified: · against the official docs listed below · Sources
Typical log lines
client intended to send too large body: 5242880 bytes
Common causes
- client_max_body_size not set; default 1m.
- The setting lives in another server/location the request does not hit.
- PHP's upload_max_filesize / post_max_size is smaller (then PHP errors, not always 413).
- A CDN or panel proxy in front has its own limit (Cloudflare free: 100 MB).
Diagnosis commands
Where and what it is set to
#
nginx -T 2>/dev/null | grep -n client_max_body_sizeConfirm nginx rejected it
#
grep 'too large body' /var/log/nginx/error.log | tail -3PHP limits
#
php -i | grep -E 'upload_max_filesize|post_max_size'Fix configs
Raise the limit
server {
client_max_body_size 100m; # 0 disables the limit (not recommended)
}Only for the upload endpoint
location /upload {
client_max_body_size 500m;
proxy_request_buffering off; # stream large uploads
proxy_pass http://127.0.0.1:3000;
}PHP side
; php.ini upload_max_filesize = 100M post_max_size = 100M ; then systemctl restart php8.3-fpm
Run nginx -t first, then systemctl reload nginx.
Key facts and sources
- client_max_body_size defaults to 1m; 0 disables the check; exceeding it returns 413. [nginx.org]
- PHP defaults: upload_max_filesize = 2M, post_max_size = 8M. [php.net]
Checked against the linked pages on 2026-11-14; the official docs win if a newer nginx changes them.
FAQ
Do I need to restart?
After nginx -t passes, systemctl reload nginx is enough. PHP changes need a PHP-FPM restart.
Which block should it go in?
http, server or location; inner overrides outer. Set a sane value per server and raise it on upload endpoints.
Fix it with a tool
Related errors
Sponsored slot (empty)
VPS / CDN recommendations may appear here later, labelled as affiliate links. There are no referral links today.
VPS / CDN recommendations may appear here later, labelled as affiliate links. There are no referral links today.