Fix client intended to send too large body: xyz bytes in Nginx

I am getting the following error when trying to upload file using Nginx web server:
    2018/01/21 12:19:23 [error] 375#375: *25019 client intended to send too large body: 3881539 bytes, client:, server:, request: “POST /cms/wp-admin/async-upload.php HTTP/2.0”, host: “”, referrer: “”
How do I fix this problem and allow file uploads upto 10MB?

The client_max_body_size directive in Nginx web server sets the maximum allowed the size of the client request body, specified in the Content-Length” request header field. If the size of a request exceeds the configured value, the 413 (Request Entity Too Large) error returned to the client. You need to configure both nginx and php (or other app) to allow upload size. Let us see how to fix client intended to send too large bod in Nginx server.

How to fix client intended to send too large body error in Nginx

First you need to edit the /etc/nginx/nginx.conf file by typing the vi command:
$ sudo vi /etc/nginx/nginx.conf
In http (server/location) section add the following directive to set the maximum allowed size in 10MB:
client_max_body_size 10M;
Save and close the file.

Test nginx configuration for error

Run the following command:
$ sudo nginx -t
Sample outputs:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

If no error means, restart the nginx web server.
$ sudo systemctl reload nginx
$ sudo service nginx reload
Verify configuration by uploading a large file. Make sure you watch nginx error log too:
$ sudo tail -f /var/log/nginx/error.log

How to configure php to accept upload upto 10MB

Edit your php.ini file and make sure the following two line present in it:
$ sudo vi /etc/php.ini
Append or edit as follows:


Save and close the file. Restart your Nginx PHP-fpm service:
$ sudo systemctl restart php-fpm
$ sudo /etc/init.d/php-fpm restart
# /usr/local/etc/rc.d/php-fpm restart
Now upload a file and test it.


In short you need the following line in nginx.conf and php.ini using the grep command/egrep command/tail command:
$ grep client_max_body_size /etc/nginx/options.conf
$ egrep 'upload_max_filesize|post_max_size' /etc/php/7.0/fpm/conf.d/99-custom.ini
$ tail -f /var/log/nginx/error.log
$ tail -f /var/log/nginx/php-fpm-error.log

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Comments on this entry are closed.

Comments are closed. Still have questions? Post it on our forum