What the 413 Request Entity Too Large Error Means
The 413 request entity too large error appears when a file upload or form submission is bigger than the limit Nginx allows. The browser uploads the file, Nginx rejects it before the application ever sees it, and the user gets a plain error page. This guide shows how to fix 413 request entity too large in Nginx by raising client_max_body_size in the right place, and how to handle the application-level limits that sit behind it.
Nginx defaults to a 1 MB body size limit. That is fine for text forms but far too small for media uploads, backups, or migration files. WordPress users hit this error when uploading themes, plugins, or large images, and site migrations fail on it constantly. The fix is one directive, but it must live in the right context, and PHP and WordPress have their own limits that must match. Raising only the Nginx limit and ignoring the rest leaves the error in place with a different cause.
First, confirm the error is really from Nginx. Check the error log for a “client intended to send too large body” entry:
sudo tail -n 30 /var/log/nginx/error.log | grep "too large body"
If that entry exists, Nginx rejected the request. If it does not, the rejection came from the application or from PHP, and the Nginx change alone will not help. Keep that distinction in mind while working through the steps.
Set client_max_body_size in Nginx
The client_max_body_size directive sets the maximum allowed request body. Add it to the server block for the site, or to a specific location if only one upload path needs a larger limit:
server {
server_name example.com;
client_max_body_size 64M;
location /wp-admin/ {
client_max_body_size 128M;
}
}
A site-wide 64 MB limit with a larger 128 MB limit for the admin area is a sensible pattern for WordPress. Setting the limit at the http level applies it to every site on the server, which is convenient but risky if one site should stay strict. A location-level limit overrides the server-level value for that path only, which is the most precise option when a single upload endpoint needs more room.
After editing, test and reload:
sudo nginx -t
sudo systemctl reload nginx
Test with a real upload, not just a configuration test. A syntax check only proves the file parses, not that the limit applies to the path you care about. If the error persists after a reload, verify you edited the active server block. Sites with multiple blocks for the same domain, including a redirect block for HTTP, are a common source of editing the wrong file. The server block layout is explained in the guide to setting up Nginx server blocks on Ubuntu 24.04.
Match the PHP Upload Limits
Once Nginx accepts the body, PHP applies its own limits. Edit php.ini for your PHP version and set both values above your Nginx limit:
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300
The post_max_size value must be at least as large as upload_max_filesize, because the whole form submission counts against it, not just the file. The execution time matters for slow connections: a large file on a slow upload can exceed the default 30 seconds and fail with a timeout instead of a size error. Restart PHP-FPM after editing:
sudo systemctl restart php8.3-fpm
Replace 8.3 with your PHP version. WordPress adds one more layer: some hosts and plugins set their own upload caps, and the media library may still show a smaller limit after the server change. Check the media upload screen after restarting, and clear any caching plugin’s cache if the old value is still displayed. A Nginx 413 upload error that survives both the Nginx and PHP changes usually points to a plugin or a CDN rule, so disable upload-related plugins one at a time to isolate it.
Fix 413 Errors on Migrations and Proxied Uploads
Site migrations are where this error hurts most, because the file being uploaded is the whole site. If you are moving a WordPress site, the migration guide for migrating WordPress from shared hosting to a VPS covers the upload step, and a separate walkthrough for moving a WordPress site from cPanel to a VPS covers the same problem from the cPanel side. In both cases, raise the limits before starting the migration, not after it fails halfway through.
Proxied setups need the limit on both sides. If Nginx proxies to an application server that runs its own Nginx, or to a backend with its own body limit, the stricter side wins. Set client_max_body_size on the front proxy and on the backend, and check the backend’s own framework limits as well. Cloudflare users should also check the plan’s upload limit: free plans cap uploads at 100 MB regardless of your server settings, and no server change overrides that. For uploads above that cap, bypass the proxy for the upload path or split the file.
This Nginx upload limit is the value to quote when support asks why an upload failed, because it is the first gate the request hits. Finally, do not set the limit to 0, which disables it entirely, unless you have a specific reason and a trusted upload path. An unlimited body size lets anyone send huge requests at your server, which is a cheap denial-of-service vector. A generous but finite limit, such as 128 MB or 256 MB, covers real uploads while keeping abuse bounded. To increase the upload limit in Nginx safely, pick the smallest value that covers your largest legitimate file and document it, so the next person who touches the configuration knows why it is there.