What Causes the 413 Error?
Nginx rejects request bodies larger than the configured maximum. Even after updating Nginx, PHP-FPM, WordPress, or a reverse proxy can still enforce a lower limit and continue failing uploads.
Step 1: Increase Nginx Limit
Add or update client_max_body_size in the correct block (server or http).
sudo nano /etc/nginx/nginx.conf
http {
client_max_body_size 64M;
}
Or set per site in your vhost:
server {
server_name example.com;
client_max_body_size 64M;
}
Step 2: Validate and Reload Nginx
sudo nginx -t
sudo systemctl reload nginx
Step 3: Match PHP Upload Limits
If you run PHP apps or WordPress, set matching values:
sudo nano /etc/php/8.3/fpm/php.ini
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
sudo systemctl restart php8.3-fpm
Step 4: Verify End-to-End
- Upload a file slightly below and above your new limit.
- Check Nginx logs:
/var/log/nginx/error.log. - If using Cloudflare or another proxy, verify its body size limit too.
Quick Troubleshooting Checklist
# find all body size directives
sudo nginx -T | grep -n client_max_body_size
# test configuration
sudo nginx -t
# tail logs during upload
sudo tail -f /var/log/nginx/error.log
FAQ
Where should I set client_max_body_size?
Set it in the narrowest scope you need (specific site/server block). Use global http only when all sites share the same limit.
Does this affect download size?
No. It limits incoming request body size, mainly uploads and large POST requests.
Why do I still see 413 after editing Nginx?
Another layer likely limits size: PHP, app framework, or CDN/proxy.
Related fixes: Nginx 502 guide and disk cleanup for failed uploads.