How to Fix 413 Request Entity too Large Error in WordPress
Have you ever tried to upload a file to WordPress only to get the 413 Request Entity Too Large error? Isn’t it annoying? Don’t worry, we’ve got a solution! We’ll show you how to fix the 413 Request Entity Too Large error in WordPress in this article.
|413 Request Entity Too Large
|413 Payload Too Large
HTTP Status Code 413
|Request too large
PHP limits too low
The page was not displayed because the request entity is too large.
What Does 413 Request Entity Too Large Error Mean?
The 413 Request Entity Too Large error means that the client’s request is too large to be processed by the server. The 413 error commonly occurs when uploading a file larger than the set server limit.
Hosting providers tend to have specific configurations on their servers for uploading media to WordPress, and in most cases, these default settings provide sufficient resources for your posts and uploads.
However, in certain cases, you might need to upload a file that exceeds the size limit, and you will unfortunately face the 413 error.
This issue is somewhat related to the 400 Bad Request error. While the 400 error typically signals a general issue with the request, it can sometimes occur in scenarios related to request size, similarly to a 413 error.
How to Fix 413 Request Entity Too Large Error in WordPress
Luckily, there are a few ways to fix this issue. We will teach you four different methods of how to deal with the error 413 on WordPress.
Important! Two of the methods deal with important WordPress files, so we strongly suggest you back up your files before starting any configuration.
1. Modify the functions.php file
You can find the functions.php file in your WordPress themes folder. This file is often used to define ‘classes’ and ‘actions’ on your WordPress site. It can add features and functionality like enabling post thumbnails, post formats, and navigation menus.
Make sure to apply this modification in the child theme. This way, all of the changes you made won’t be overwritten when updating the parent theme.
To modify functions.php access your Hostinger Control Panel. Then, go to the File Manager under the Files section.
In the Hostinger File Manager, you will see three folders under the public_html folder. Click on the wp-content folder that will give you a list of files on the right side. Double click on themes folder to find the functions.php file. Make sure you choose the file of the theme you are currently using.
Double click the functions.php file and add the following code snippet. It will increase It will increase upload_max_size, post_max_size and max_execution_time values.
@ini_set( 'upload_max_size' , '256M' ); @ini_set( 'post_max_size', '256M'); @ini_set( 'max_execution_time', '300' );
After you are finished, save the changes and try head back to WordPress admin area to test if you still get HTTP 413 error.
2. Modify .htaccess file
The second method involves editing the .htaccess file, so be cautious not to make any unnecessary changes.
The .htaccess file is a configuration item which is read by the server. It can override server configuration settings for things like authorization, caching, or even optimization.
To reach the .htaccess file, you need to go to your public_html folder in your Hostinger control panel. On the right side, you will see the .htaccess file. Double click on it.
You will get a popup window where you can add in the code. Read through the lines, when you find # END WordPress at the end of the file, paste in the following code under it:
php_value upload_max_filesize 256M php_value post_max_size 256M php_value max_execution_time 600 php_value max_input_time 600
Make sure you save the modification and close the window. Go back to WordPress admin area and try upload a new.
3. Modify NGINX Configuration
If you use VPS hosting, you’ll get control over most of your server environment. We only reach basic server software (Apache or NGINX) in its default state. That means if you want to tweak more, you are free to revise it.
When the web server is set to restrict large file sizes, it can cause the 413 error request entity too large. NGINX has client_max_body_size to allow the maximum size of the client request body. If the request exceeds the value, an error message emerges. That means we need to reconfigure NGINX to allow the size we want for uploading files.
Reconfiguring nginx.conf will require a text editor. We recommend Vi text editor as it will handle the job perfectly.
Access your VPS via SSH and type the following command on your terminal to start editing with Vi:
After that, you can add the following lines in nginx.conf as shown in the example below. It sets the maximum body size of a client request that the server allows. So, make sure you put the right number as your maximum size.
# set client body size to 8M # client_max_body_size 8M;
Save and close the file. Then, you can reload the NGINX web server with this following command:
# nginx -s reload
Now, you can go ahead and check if the error 413 is gone.
4. Use a WordPress plugin
This free plugin lets you bypass your server’s upload limits, including the ones imposed by CDN, without changing your PHP files or settings.
After installing the plugin, navigate to Settings → Big File Uploads to configure the plugin. You can set the maximum upload size for all users or by user roles.
You can also change the upload limit in the Media Library area.
Troubleshooting Other 4xx Errors
If you try to upload a file that is larger than what your server allows, WordPress will display the 413 Request Entity Too Large error. In this tutorial, we looked at four different ways to fix the 413 error.