Skip to main content
wordpress Beginner Level 8 min read

How to Fix “413 Request Entity Too Large” Error in Nginx and WordPress

A complete guide to fix HTTP 413 Request Entity Too Large errors in Nginx and WordPress. Increase client_max_body_size, configure PHP upload limits, and handle Cloudflare payload restrictions.

SC
ServerCare360 Systems Team
Senior Web Infrastructure Engineer
Published: Sep 18, 2026

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

  1. Open your Nginx server block or nginx.conf:
    # Add inside the http, server, or location block:
    client_max_body_size 64M;
  2. Test Nginx syntax and reload:
    sudo nginx -t && sudo systemctl reload nginx
  3. Update your php.ini file:
    upload_max_filesize = 64M
    post_max_size = 64M
    memory_limit = 256M
    max_execution_time = 300
  4. 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

  1. Nginx client_max_body_size Default: Nginx defaults to a strict 1m (1 Megabyte) limit if no explicit directive is set.
  2. PHP upload_max_filesize Too Low: PHP defaults to 2M, causing PHP-FPM to reject larger file streams.
  3. PHP post_max_size Too Low: If post_max_size is smaller than upload_max_filesize, any form submission carrying the file is rejected.
  4. 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.
  5. 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., 64M or 128M). 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 the http { ... } block of /etc/nginx/nginx.conf to 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_time to 300 ensures 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

  1. Bypass Cloudflare for Uploads: Upload large backups or zip archives via SFTP/SSH directly into the server instead of through the browser.
  2. 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

  1. Navigate to Plugins -> Add New -> Upload Plugin in your WordPress admin.
  2. Upload the zip file that previously failed.
  3. Verify that the upload completes without error and presents the plugin installation confirmation screen.

Common Mistakes

  1. Setting post_max_size smaller than upload_max_filesize: If you set upload_max_filesize = 64M but forget to increase post_max_size (leaving it at 8M), any upload larger than 8MB fails silently.
  2. Editing the CLI php.ini instead of the FPM php.ini: On Ubuntu/Debian, /etc/php/8.2/cli/php.ini affects only command-line scripts. You must edit /etc/php/8.2/fpm/php.ini for web traffic.
  3. 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 (64M to 128M) matching actual business requirements.
  • Maintain adequate free space in /tmp and /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 FileDirectiveValue
nginx.confclient_max_body_size64M;
php.iniupload_max_filesize64M
php.inipost_max_size64M
php.inimemory_limit256M
php.inimax_execution_time300

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.

Was this technical guide helpful?
SC
ServerCare360 Systems Team Author
Senior Web Infrastructure Engineer

Specializing in high-throughput Nginx reverse proxies, PHP-FPM optimization, and WordPress enterprise hosting.

Production Standards Verified by Lead Infrastructure Architect
Keep Troubleshooting & Reading

Related Troubleshooting Guides

Explore All Guides
24/7 Managed Server Administration

Need Certified Engineers to Manage this Stack?

ServerCare360 provides proactive monitoring, zero-downtime migrations, and rapid SLA incident response.

View All Services
Infrastructure Support

Require Proactive Infrastructure Monitoring & Support?

Prevent recurring outages, high load spikes, and backup failures with our 24/7 remote server administration.