Where to raise the limit
Keeping client_max_body_size 1m; globally in http and raising it only on the upload route is safer than opening 100m for every site on the server (Hardening):
location /upload {
client_max_body_size 64m;
client_body_timeout 60s;
proxy_pass http://127.0.0.1:3000;
}
For PHP-FPM on Ubuntu 24.04, also update /etc/php/8.3/fpm/php.ini (on Ubuntu 26.04, /etc/php/8.5/fpm/php.ini):
upload_max_filesize = 64M
post_max_size = 68M
If it doesn’t work
Uploading a 3 MB photo fails immediately with 413 Request Entity Too Large before reaching the app
- Cause
client_max_body_sizeisn’t set, so nginx enforces its1mdefault.- Fix
- Add
client_max_body_size 32m;to the targetlocationorserver, then runsudo nginx -t && sudo systemctl reload nginx.
Setting client_max_body_size 64m; cleared 413, yet WordPress still rejects files over 2 MB
- Cause
- PHP’s own limits in
/etc/php/8.3/fpm/php.inikicked in:upload_max_filesize = 2Mandpost_max_size = 8M. - Fix
- Raise both settings in
php.ini(keeppost_max_sizeslightly larger thanupload_max_filesize) and reloadphp8.3-fpm(PHP-FPM).