Ever tried uploading a file to WordPress only to see the 413 Request Entity Too Large error pop up? Annoying, right? Well don’t worry, we have a solution! In this article, we will teach you how to fix the 413 Request Entity Too Large error in WordPress.
What 413 Request Entity Too Large Error Means?
In short, the 413 Request Entity Too Large error happens when you try uploading a file too large for your server. Typically, hosting providers have specific configurations on their server for uploading media to WordPress. In most cases, the default settings are more than enough for your posts.
However, in some 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 quite a few ways to fix this issue. We will teach you three different methods of how to deal with the error 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. Modifying 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 413 error.
2. Modifying .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 CPanel. 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. Modifying Nginx Configuration
If you use a Hostinger VPS server, 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.
413 error request entity too large happens because the web server is set to restrict large file sizes. 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
If you want to upload a file larger than allowed by your server, you will face the 413 Request Entity Too Large error in WordPress. In this tutorial we overviewed 3 different methods to fix 413 error.
This post was last modified on May 18, 2021 5:23 pm