413 Request Entity Too Large on Media Upload (Nginx/Apache)
If you encounter the 413 Request Entity Too Large error when uploading media files to WordPress, it means your server is rejecting files that exceed its configured size limits. This is a common issue that can be quickly fixed by adjusting server settings.
Quick Fix
- For Nginx, increase the
client_max_body_size
directive. - For Apache, increase the
LimitRequestBody
directive. - Restart or reload your web server to apply changes.
Why This Happens
Web servers limit the size of HTTP request bodies to protect against resource exhaustion and abuse. When uploading large files, if the file size exceeds these limits, the server responds with a 413 error, blocking the upload. WordPress itself also has upload size limits, but this error originates from the web server before WordPress processes the file.
Step-by-step Fix per Server
1. Fix for Nginx
The client_max_body_size
directive controls the maximum allowed size of the client request body, which includes file uploads.
- Open your Nginx configuration file. This is usually located at:
/etc/nginx/nginx.conf
- or inside your site-specific config in
/etc/nginx/sites-available/
- Find the
http
,server
, orlocation
block where you want to set the limit. - Add or update the directive, for example to allow 64MB uploads:
client_max_body_size 64M;
- Save the file and test the configuration:
sudo nginx -t
- If the test is successful, reload Nginx:
sudo systemctl reload nginx
2. Fix for Apache
Apache uses the LimitRequestBody
directive to limit the size of the HTTP request body.
- Open your Apache configuration file or your site’s
.htaccess
file. Common locations: /etc/apache2/apache2.conf
or/etc/httpd/conf/httpd.conf
- Or inside your site root’s
.htaccess
- Add or update the directive inside the appropriate context (e.g.,
<Directory>
or globally):
LimitRequestBody 67108864
This example sets the limit to 64MB (64 * 1024 * 1024 bytes).
- Save the file.
- Restart Apache to apply changes:
sudo systemctl restart apache2
# or on CentOS/RHEL
sudo systemctl restart httpd
3. Verify WordPress PHP Upload Limits
Even after adjusting server limits, PHP settings can restrict upload size. Check and update these values in your php.ini
or via your hosting control panel:
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 128M
Restart PHP-FPM or your web server if needed.
Works on
Server | Control Panel | Applicable Directives |
---|---|---|
Nginx | cPanel, CloudPanel, Plesk, Custom | client_max_body_size |
Apache | cPanel, CloudPanel, Plesk, Custom | LimitRequestBody , php.ini upload limits |
FAQ
- Q: How do I know if the 413 error is caused by Nginx or Apache?
- A: Check your server stack. If you use Nginx as a reverse proxy in front of Apache, both may have limits. Start by increasing Nginx’s
client_max_body_size
. If only Apache is used, adjustLimitRequestBody
. - Q: Can I set these limits in WordPress instead?
- A: WordPress settings like
upload_max_filesize
andpost_max_size
in PHP control upload limits, but the 413 error is a server-level rejection. You must increase server limits first. - Q: What if I don’t have access to the server config files?
- A: Contact your hosting provider to increase upload size limits or use their control panel if available. Some hosts allow changing PHP and server limits via cPanel or Plesk interfaces.
- Q: Will increasing these limits affect server security?
- A: Larger limits allow bigger uploads but can increase resource usage and risk of abuse. Set limits according to your site’s needs and monitor server performance.
- Q: After changing the limits, the error persists. What else can I check?
- Clear your browser cache, restart your web server and PHP services, and verify PHP upload limits. Also, check for any reverse proxies or firewalls that might impose their own limits.