When attempting to upload a large media file, import a database backup, or install a premium theme or plugin zip in WordPress, you may suddenly encounter the error: “413 Request Entity Too Large”.
This HTTP status code indicates that the web server or reverse proxy received a request whose body payload exceeds the maximum size configured in server directives. By default, Nginx restricts client request bodies to just 1 Megabyte (1MB).
Fixing this error requires aligning your Nginx web server buffer limits with your PHP upload configurations.
Quick Answer
- Open your Nginx server block or
nginx.conf:# Add inside the http, server, or location block: client_max_body_size 64M; - Test Nginx syntax and reload:
sudo nginx -t && sudo systemctl reload nginx - Update your
php.inifile:upload_max_filesize = 64M post_max_size = 64M memory_limit = 256M max_execution_time = 300 - Reload PHP-FPM:
sudo systemctl reload php8.2-fpm
Symptoms
- Uploading a theme or plugin zip in WordPress returns a blank popup with: “413 Request Entity Too Large” and an Nginx footer tag.
- Media library file uploads stop at 100% and report an HTTP upload error.
- Large REST API POST requests (such as batch product imports in WooCommerce) fail immediately with status 413 in browser developer tools (
F12 -> Network). - Nginx error log records:
client intended to send too large body: XXXXX bytes.
Common Causes
- Nginx
client_max_body_sizeDefault: Nginx defaults to a strict1m(1 Megabyte) limit if no explicit directive is set. - PHP
upload_max_filesizeToo Low: PHP defaults to2M, causing PHP-FPM to reject larger file streams. - PHP
post_max_sizeToo Low: Ifpost_max_sizeis smaller thanupload_max_filesize, any form submission carrying the file is rejected. - Cloudflare Edge Limit: Cloudflare Free and Pro plans enforce a hard 100MB upload limit per HTTP request. Uploads larger than 100MB are blocked at the Cloudflare edge before reaching Nginx.
- FastCGI Buffer Overflow: PHP-FPM temporary upload directories running out of space or lacking write permissions.
Before You Start
- Determine the maximum file size you realistically need (e.g.,
64Mor128M). Avoid setting unlimited sizes (0) on public servers to prevent Denial-of-Service attacks. - Check whether your site sits behind a reverse proxy or CDN like Cloudflare.
- For custom web server tuning, review our WordPress server support services.
Step 1 — Increase Nginx client_max_body_size
Open your site’s Nginx configuration file (typically in /etc/nginx/sites-available/ or /etc/nginx/conf.d/):
sudo nano /etc/nginx/sites-available/yourdomain.com.conf
Locate the server { ... } block and add the client_max_body_size directive:
server {
listen 443 ssl http2;
server_name yourdomain.com;
root /var/www/html;
# Set maximum upload body size to 64 Megabytes
client_max_body_size 64M;
# ... remaining server configuration ...
}
Global Setting Tip: If you manage multiple sites on the same server, you can set
client_max_body_size 64M;inside thehttp { ... }block of/etc/nginx/nginx.confto apply the limit across all virtual hosts.
Test and Reload Nginx
Always test your Nginx configuration syntax before reloading:
sudo nginx -t
If the test reports syntax is ok and test is successful, reload Nginx:
sudo systemctl reload nginx
Step 2 — Configure PHP Upload and Post Directives
Nginx handles the initial connection, but PHP-FPM processes the file. If PHP has lower thresholds, Nginx will pass the request, but PHP will throw an internal upload error.
Locate your active php.ini file:
php -i | grep "Loaded Configuration File"
Edit the file (for example, /etc/php/8.2/fpm/php.ini):
sudo nano /etc/php/8.2/fpm/php.ini
Find and adjust these four directives:
; Maximum allowed size for uploaded files.
upload_max_filesize = 64M
; Must be greater than or equal to upload_max_filesize
post_max_size = 64M
; Maximum amount of memory a script may consume
memory_limit = 256M
; Maximum execution time of each script, in seconds
max_execution_time = 300
max_input_time = 300
Critical Sizing Rules
memory_limit$\ge$post_max_size$\ge$upload_max_filesize- Increasing
max_execution_timeto300ensures slow mobile uploads do not time out before completing.
Step 3 — Reload PHP-FPM
Apply the updated php.ini settings by reloading your PHP-FPM service:
# For PHP 8.2 on Ubuntu/Debian:
sudo systemctl reload php8.2-fpm
# For PHP on AlmaLinux/Rocky Linux/RHEL:
sudo systemctl reload php-fpm
Verify that the new values are recognized:
php -r "echo ini_get('upload_max_filesize') . PHP_EOL;"
The output should confirm 64M.
Step 4 — Adjust WordPress Settings in wp-config.php
To ensure the WordPress admin dashboard updates its media uploader labels, add these definitions to wp-config.php:
@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );
Log in to /wp-admin/ and navigate to Media -> Add New Media File. Look at the line under the upload box:
Maximum upload file size: 64 MB.
If it reflects your new 64MB limit, the configuration is synchronized across all layers.
Step 5 — What to Do If You Use Cloudflare (100MB Limit)
If your website uses Cloudflare CDN, you may notice that uploads under 100MB work perfectly, but any file over 100MB returns a Cloudflare-branded 413 Request Entity Too Large error.
- Cloudflare Free, Pro, and Business plans enforce a hard request body limit of 100MB.
- Cloudflare Enterprise plans allow uploads up to 500MB.
Solutions for Cloudflare Limits
- Bypass Cloudflare for Uploads: Upload large backups or zip archives via SFTP/SSH directly into the server instead of through the browser.
- Use Chunked Uploads: Plugins that support chunked uploading (such as WP All Import with chunking or cloud storage offloaders) split large files into small 5MB parts that bypass Cloudflare and Nginx limits.
Step 6 — Verify Resolution
- Navigate to Plugins -> Add New -> Upload Plugin in your WordPress admin.
- Upload the zip file that previously failed.
- Verify that the upload completes without error and presents the plugin installation confirmation screen.
Common Mistakes
- Setting
post_max_sizesmaller thanupload_max_filesize: If you setupload_max_filesize = 64Mbut forget to increasepost_max_size(leaving it at8M), any upload larger than 8MB fails silently. - Editing the CLI php.ini instead of the FPM php.ini: On Ubuntu/Debian,
/etc/php/8.2/cli/php.iniaffects only command-line scripts. You must edit/etc/php/8.2/fpm/php.inifor web traffic. - Setting
client_max_body_size 0: Setting size to 0 disables checking entirely, allowing attackers to upload gigabyte-sized payloads that exhaust server RAM and disk space.
Prevention Checklist
- Set appropriate upload limits (
64Mto128M) matching actual business requirements. - Maintain adequate free space in
/tmpand/var/lib/php/sessions. - Monitor web traffic using our infrastructure monitoring tools.
- Use WP-CLI (
wp plugin install <url>) to install heavy extensions from the command line without browser upload constraints.
Quick Reference Directives
| Configuration File | Directive | Value |
|---|---|---|
nginx.conf | client_max_body_size | 64M; |
php.ini | upload_max_filesize | 64M |
php.ini | post_max_size | 64M |
php.ini | memory_limit | 256M |
php.ini | max_execution_time | 300 |
Frequently Asked Questions
Can .htaccess fix a 413 error if I run Nginx?
No. .htaccess is an Apache configuration file. If your web server is Nginx (or Nginx reverse proxy in front of Apache), Nginx intercepts the HTTP request before .htaccess is ever read. You must configure client_max_body_size in Nginx.
Does increasing upload limits slow down my server?
No. The setting simply defines the ceiling. Small 20KB requests still process at normal speed. However, allocating sufficient RAM via memory_limit prevents server memory pressure when handling concurrent uploads.
How do I check Nginx upload errors in the log?
Search /var/log/nginx/error.log for the phrase:
grep "client intended to send too large body" /var/log/nginx/error.log
How does ServerCare360 help optimize web server configurations?
Our WordPress server support and Linux server support engineers configure optimized Nginx reverse proxies, balance PHP-FPM worker pools, and ensure reliable file upload pipelines for high-traffic platforms.