Digity Republic

Tech News, Reviews, Deals, and How-To's

WordPress with Nginx 413 Request Entity too Large Fix

WordPress with Nginx

image of WordPress with Nginx

This little article demonstrates how to fix a problem that arises frequently with WordPress when users attempt to upload files, media, or other types of data and see a “413 Request Entity Too Large” issue through Nginx.

When you try to upload something or make a client request that is too big for the web server, in this example an Nginx HTTP server, to handle, you get the 413 request entity too large error.

Your users or clients may frequently see this error if the server configuration has a request size restriction that is too tiny. Therefore, you should probably change the web server settings to permit bigger queries.

Allowing file uploads via the WordPress media library over the server is one of the frequent problems webmasters run into while handling WordPress.

Users can upload new themes and plugins to WordPress, but if your Nginx-powered website isn’t set up to support massive file uploads, the upload procedure will always fail.

WordPress users frequently have the following issues when dealing with file uploads:

  • When trying to upload media, an HTTP error occurs.
  • The upload max filesize directive in php.ini is exceeding the uploaded file.
  • exceeded the maximum execution time.
  • depleted memory space, among other things.

Please create a system backup before moving on to the next stages.

WordPress with Nginx: Set up the directory permissions for WordPress.

Make sure the directory where WordPress is installed has the appropriate permissions for the Nginx web server to execute, first. The root directory on an Ubuntu system is typically locatng at /var/www/Html.

To provide the Nginx web server full access to that directory, use the instructions below.

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

WordPress with Nginx: Reconfigure PHP-FPM settings

Make further PHP-FPM configuration adjustments to enable bigger file uploads. There is a default restriction on the maximum file size that PHP-FPM may upload. Set the PHP-FPM directives for the file upload size restriction and other things.

The following file houses the default PHP-FPM settings for Ubuntu 18.04 and later:


The x in the previous line can be a 0, 1, 2, 3, or 4.

Run the instructions listed below to open the PHP-FPM configuration file, then modify the values to fit your environment.

sudo nano /etc/php/7.2/fpm/php.ini

Next, line by line through the file, change each directive with the value shown below:

memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 100M
file_uploads = On
max_execution_time = 600
max_input_time = 600

Save your edits.

Adjust the upload max file size so that it is bigger than the file size if the file you are uploading is larger than 100MB.

WordPress with Nginx: Change the Nginx settings

Also, Nginx has its own definitions for limits.

Anything you change in the PHP configuration file could not apply to Nginx if you don’t declare the size limit in the Nginx configuration. Open Nginx settings and add the following values to allow Nginx to upload bigger files as well:

Nginx default site configuration files are kept at /etc/nginx/sites-available/default on Ubuntu systems.

If there is a custom file there, change the values that are highlighted as well.

server {
    listen 80;
    listen [::]:80;
    root /var/www/html/wordpress;
    index index.php index.html index.htm;
    server_name example.com www.example.com;

    client_max_body_size 100M;

location / {
    try_files $uri $uri/ /index.php?$query_string;

location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
      fastcgi_connect_timeout 300s;
      fastcgi_read_timeout 300s;
      fastcgi_send_timeout 300s;

Save the file, then carry on.

Finally, to make the updated settings effective, restart Nginx and PHP-FPM.

sudo systemctl reload nginx.service
sudo systemctl reload php7.2-fpm.service

Go ahead and attempt to upload a file that is less than 100 MB in size.

This must suffice.

Frequently Asked Questions:

How can I repair the Nginx error 413?

Client max body size changes and error 413 “Request Entity Too Large” in the Nginx configuration file. This is taking place because your nginx server forbids uploading files that are larger than what is specified in the nginx configuration file. You need to change your nginx settings to fix the issue.

The 413 Request Entity Too Large Nginx error means what?

The meaning of “413 Request Entity Too Large” When a client’s request is larger than the server’s permitted file size, a 413 HTTP error message is returned. This frequently occurs when a client tries to upload a sizable file to a web server, and the server alerts the client with a 413 error.

Why am I receiving Request Entity Too Large so frequently?

You can occasionally get an error notice that says “Request Entity Too Large” while navigating your account. When this occurs, it indicates that you need to clear the cookies that Constant Contact has stored on your computer.

The meaning of HTTP Error 413

The server may cancel the connection or return a Retry-After header field if the request entity exceeds the server’s set limitations, as shown by the HTTP 413 Payload Too Large response status code.

Read more:

Do You Need More Help?

Visit our forum, describe your question briefly and get answers