Laravel Valet Nginx error 413: Request entity too large – Fix

This morning I wanted to install WooCommerce Storefront and I got a Laravel Valet Nginx error 413:

Error 413: Request entity too large

This was a new error for me I had never encountered before. This because most Nginx setups have dealt with this issue and because Laravel is just new to the whole LEMP setup.

Client Max Body Size

PHP settings were fine and were not the issue. This was an Nginx error. I needed to enlarge the:


You can read more about it at Nginx here.

NGINX Site Config

To do that you have to edit the nginx file for your site. So on OSX (Mac) you open it with sublime from the terminal like so:

sublime /Users/user/.valet/Nginx/

Server Block Update

At the beginning of the server block for port 443 (if you are running it secure) you should add this line

 client_max_body_size 500M;

You can make the amount in Megabytes smaller of course, but doing it all locally this should be fine. And then it should look like something like:

server {
 listen 443 ssl http2;
 root /;
 charset utf-8;
 client_max_body_size 500M;

If you are running the site using HTTPS so not secure it will be the server block for port 80 where you need to add the line.

NB Test with (sudo) nginx -t

Restart Nginx

Once done restart the server doing a:

valet restart

or a

sudo nginx -s stop && sudo nginx

should do the trick and restart the http server – Nginx. After that you should be good to go!

Tagged in : Tagged in : , ,
Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.