File upload limit in Nginx & (The server returned a "413 Content Too Large")

✔ Recommended Answer

You also have to edit your php.ini which is currently loaded. You can find this from <?php phpinfo(); then edit the following.

memory_limit = 64Mupload_max_filesize = 100Mpost_max_size = 100M


Answered By: Michael Mano

 By default, Nginx has a limit on the maximum size of the file that can be uploaded to the server. This limit is specified by the client_max_body_size directive in the Nginx configuration file.

If you are seeing the "413 Content Too Large" error, it means that the size of the file being uploaded exceeds the limit set by client_max_body_size.

To increase the limit, you need to edit the Nginx configuration file (usually located in /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf) and add or modify the client_max_body_size directive to a value that suits your needs. For example, to allow file uploads of up to 100MB, you can add the following line to your configuration file:

client_max_body_size 100m;

After modifying the configuration file, you need to restart the Nginx server for the changes to take effect:

sudo service nginx restart
Note that increasing the file upload limit can have security implications, as it may allow users to upload large files that could potentially overwhelm the server or cause other problems. It is therefore important to set a reasonable limit based on your server's resources and requirements.


Most Popular

PhpStorm, return value is expected to be 'A', 'object' returned

Remove Unicode Zero Width Space PHP

Laravel file upload returns forbidden 403, file permission is 700 not 755