WEB SERVER
June 23, 2026

How to Increase Upload File Size Limits in Nginx and PHP

7 min read
Author
CloudStick Team
Security Specialist
Share this article
Increase Upload File Size Limits in Nginx and PHP
CloudStick
Upload Limits in Nginx

Default Upload Limits and Where They Come From

Upload size is controlled at two independent layers: Nginx and PHP. Nginx has a default client_max_body_size of 1MB. PHP has upload_max_filesize (default 2MB) and post_max_size (default 8MB). Both layers enforce their own limit independently — you must increase both, and Nginx must be set at least as high as PHP.

The typical symptom is a 413 Request Entity Too Large error from Nginx when the file exceeds client_max_body_size. If Nginx passes the request but PHP rejects it, WordPress shows a vague "HTTP error" — this usually means PHP's upload_max_filesize limit was hit.

Set Nginx client_max_body_size

Add client_max_body_size to your server block. Setting it in the server block applies it to all locations in that block. You can also set it per-location if only specific endpoints (like an upload handler) need a higher limit.

# Inside your server {} block
server {
listen 443 ssl;
server_name example.com;
# Increase upload limit to 64MB
client_max_body_size 64M;
# Optionally limit to specific upload location:
location /wp-admin/async-upload.php {
client_max_body_size 64M;
}
}

Update PHP.ini Settings

PHP enforces two upload-related limits: upload_max_filesize caps a single file, while post_max_size caps the entire POST request body including all files and form fields combined. Set post_max_size slightly higher than upload_max_filesize to account for the form data overhead.

# Edit PHP configuration
sudo nano /etc/php/8.3/fpm/php.ini
# Find and update these lines:
upload_max_filesize = 64M
post_max_size = 72M
max_execution_time = 300
max_input_time = 300
memory_limit = 256M

Reload PHP-FPM and Nginx

PHP-FPM reads php.ini at startup, not on each request. After editing php.ini you must restart or reload PHP-FPM for the changes to take effect. Nginx also needs a reload after you change client_max_body_size.

# Reload PHP-FPM (replace 8.3 with your PHP version)
sudo systemctl reload php8.3-fpm
# Reload Nginx
sudo nginx -t && sudo systemctl reload nginx
# Verify PHP limits are active
php -i | grep upload_max
WARNING

Setting upload limits very high (500MB+) can expose your server to memory exhaustion if many large uploads arrive simultaneously. Each upload holds the file in PHP memory until processing completes. For high-traffic sites, consider handling large uploads with a dedicated upload service or object storage rather than through PHP directly.

WordPress Upload Limit

WordPress reads PHP's upload limit and displays it in Media Settings as the "Maximum upload file size". After updating PHP-FPM settings, navigate to Settings → Media in your WordPress admin to confirm the new limit is shown. If it still shows the old limit, PHP-FPM did not reload correctly — check with systemctl status php8.3-fpm.

CloudStick manages PHP configuration through its EasyPHP interface — you can set PHP memory limit, upload size, and execution time for each website independently without editing configuration files manually. Changes apply immediately on save, and CloudStick reloads PHP-FPM automatically.

Test Your Upload Limit

The easiest way to test is to create a test file of your target upload size and attempt to upload it through WordPress Media → Add New. You can also use curl to POST a file directly to confirm Nginx accepts it. A 413 response means Nginx's limit is still too low; a PHP-reported error means the PHP limit is too low.

Leave a comment
Full Name
Email Address
Message
Contents

We use cookies to improve your experience

CloudStick uses cookies to personalise content, analyse traffic and keep you signed in. Cookie Policy · Terms of Service

Manage cookies