413 Request Entity Too Large: 4 Easy Methods to Fix This WordPress Error

413 Request Entity Too Large: 4 Easy Methods to Fix This WordPress Error

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 code413 Request Entity Too Large
Error typeClient-side
Error variations413 Payload Too Large
HTTP Status Code 413
Error causesRequest too large
PHP limits too low
The page was not displayed because the request entity is too large.

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.

Hostinger's File Manager in the hPanel

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.

Functions file in wp_content folder.

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' );
Editing functions.php file to set upload max size.

After you are finished, save the changes and try head back to WordPress admin area to test if you still get HTTP 413 error.

Hostinger web hosting banner

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.

Locating Htaccess File in Hostinger Control Panel

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
Editing htaccess file to modify upload max size.

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:

vi /etc/nginx/nginx.conf

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

If the error still persists, the culprit might be at the CDN level. In this case, you can use the Big File Uploads plugin to increase your maximum upload size.

This free plugin lets you bypass your server’s upload limits, including the ones imposed by CDN, without changing your PHP files or settings.

Big File Uploads plugin banner.

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.

Setting the maximum upload size via Big File Uploads plugin.

You can also change the upload limit in the Media Library area.

WordPress media library with the setting to change the maximum upload size highlighted.

Conclusion

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.

Author
The author

Leonardus Nugraha

Leo is a Content Specialist and WordPress contributor. Armed with his experience as a WordPress Release Co-Lead and Documentation Team Representative, he loves sharing his knowledge to help people build successful websites. Follow him on LinkedIn.