413 Request Entity Too Large, or uploads fail silently
A size limit is being hit at one of three separate layers, and all three have to agree.
What you see
Uploads over a certain size fail — sometimes with a 413, sometimes with a blank page or a silent failure that the application reports as an empty file.
What is actually wrong
nginx, PHP and the application each impose their own limit. The smallest wins, and the error you see depends on which one it was.
Codes and articles
The fix
Raise every limit in the chain
Uploads fail above a size.
Read the current values at each layer.
grep -rn client_max_body_size /etc/nginx/ 2>/dev/nullphp -i | grep -E 'upload_max_filesize|post_max_size|memory_limit|max_file_uploads'
Setting one and not the others produces a different failure at the next layer down, which is why this often takes three attempts. Reading all three first makes it one change.
Raise the nginx limit, in the server or location block that serves the upload path.
sudo sed -i '/http {/a\ client_max_body_size 64M;' /etc/nginx/nginx.confsudo nginx -t && sudo systemctl reload nginx
Raise the PHP limits. post_max_size must be larger than upload_max_filesize, and memory_limit larger than both.
sudo sed -i 's/^upload_max_filesize.*/upload_max_filesize = 64M/; s/^post_max_size.*/post_max_size = 72M/; s/^memory_limit.*/memory_limit = 256M/' /etc/php/8.2/fpm/php.inisudo systemctl restart php8.2-fpm
Check the application's own limit — most content management systems have one in their settings as well.
Raise the timeouts to match. A 64MB upload on a slow connection can exceed the read timeout and fail as a 504 instead.
grep -rn 'client_body_timeout\|fastcgi_read_timeout' /etc/nginx/
php -i | grep -E 'upload_max_filesize|post_max_size'curl -sI -X POST -F file=@test.bin http://localhost/upload | head -3
Related faults
Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.