[Solved] 413 Request Entity Too Large error on NGINX web server


A 413 Request Entity Too Large Error is an HTTP status code that occurs when a web server receives a request that is too large for it to process. This error typically occurs when the size of the data being sent by the client exceeds the maximum size allowed by the server. It can also occur if the server is unable to handle a large amount of data due to limited resources. In either case, this error prevents users from accessing content on the website and should be addressed as soon as possible. In this tutorial we discuss how to fix this error on an NGINX web server.

What Is the “Error 413 Request Entity Too Large” Error?

The “Error 413 Request Entity Too Large” error is a status code that is returned by an HTTP server when it receives a request that is too large for it to process. This error typically occurs when the size of the data being sent in a request exceeds the maximum size allowed by the server. When this happens, the server will return an error message indicating that it cannot process the request. This can be frustrating for users as they are unable to access the content they are trying to access. Knowing what causes this error and how to fix it can help users get back on track quickly and easily. The best way to determine what’s causing an error is to trace the request. Each HTTP request has a unique URL and this can be used to determine where the issue may lie.

Fixing the error by editing the NGINX config file for the affected website.

Let’s assume that you are trying to upload a file that is 500MB in size. When you try to upload the file you get the error message:

‘Error 413 Request Entity Too Large’

You then decide to inspect the virtual host log file for the website and you see the log entry shown below:


Edit the virtual host configuration file for the affected site. Usually, it is located in the /etc/nginx/sites-available/ directory. Under the server section, add the line:

This will set a limit of 1024M on the client_max_body_size parameter. Restart NGINX for the changes to take effect

Edit your WordPress functions .php file

If the error is happening on a WordPress site you can try to fix the error by editing the functions.php file. The functions.php file is an integral part of any WordPress website. It is the file that stores all the custom code and functions used to modify the behavior of your WordPress website. This file allows you to add new features, modify existing ones, and customize your website in various ways without having to write complex code. 

To edit the file, navigate to the root folder that contains all WordPress files and locate the function.php file. Run the command:

Copy and paste the configuration below:
This configuration will increase the maximum file size of posts and uploads while increasing the time the server will spend attempting to process the request.

Edit your WordPress .htaccess file

The WordPress .htaccess file is an important part of the WordPress installation. It is a configuration file that controls how your web server handles requests for your website. It can be used to secure your WordPress site, improve performance, and customize the way URLs are displayed. With the right configuration, you can make sure that only authorized users have access to certain areas of your site and prevent malicious attacks from taking place. Understanding how the .htaccess file works is essential for any WordPress user who wants to take their website’s security seriously.