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.
|Error code||413 Request Entity Too Large|
|Error variations||413 Payload Too Large|
HTTP Status Code 413
|Error causes||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 server 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.
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 three 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.
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.
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 three different ways to fix the 413 error.