A 413 response means one layer in the request path rejected the body as too large. A reliable fix aligns Nginx, PHP, WordPress, and any CDN or load balancer instead of raising one limit blindly.
Find the layer returning 413
Inspect response headers and logs. If the request never reaches PHP, changing upload_max_filesize cannot help.
curl -I https://example.com/upload
sudo tail -f /var/log/nginx/error.log
sudo nginx -T | grep -n client_max_body_size
Set client_max_body_size in the right scope
Use the narrowest server or location block that needs large uploads. Avoid increasing the limit for unrelated public endpoints.
location /wp-admin/async-upload.php {
client_max_body_size 64m;
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
Align PHP upload limits
post_max_size must exceed upload_max_filesize. Confirm which php.ini PHP-FPM actually loads and reserve enough memory and temporary disk space.
php --ini
php -i | grep -E "upload_max_filesize|post_max_size|memory_limit"
# php.ini
upload_max_filesize = 64M
post_max_size = 72M
Validate and reload safely
Run a syntax test before reload, then test files just below and above the limit. This confirms both the success path and enforcement boundary.
sudo nginx -t
sudo systemctl reload nginx
sudo systemctl reload php8.3-fpm
Control security and capacity
Validate MIME type and extension, cap processing time, monitor temporary storage, and consider direct object-storage uploads for very large files.
413 troubleshooting checklist
- Identify which layer produced 413.
- Set a scoped Nginx body-size limit.
- Align PHP and application limits.
- Check temporary and persistent storage.
- Test below and above the boundary.
Frequently asked questions
Why did changing php.ini not work?
Nginx may reject the request before PHP sees it, or PHP-FPM may load a different configuration file.
Should client_max_body_size be zero?
Zero disables the check and is rarely appropriate for a public site. A defined use-case limit is safer.
Why does a large upload later return 504?
After passing the size check, slow storage or processing may hit a separate upstream timeout.
Related guides
Official documentation
Sources last reviewed: ۳۰ سپتامبر ۲۰۲۶
