Here are two scenarios where a Valet NGINX server isn’t properly configured to handle upload great than the default of 2 MB.
- Inspect element in the browser says “413 request entity too large” when uploading a file, if using Livewire
- Installing WordPress in a Valet parked folder and then try to upload an Elementor Pro 3.3 MB file
This is the error:
413 Request Entity Too Large
On a normal NGINX server this is pretty easy to troubleshoot, navigate to somewhere like this:
/etc/nginx/sites-available/sitename.conf
Add this:
client_max_body_size 20M;
in SSL section. See below for another example.
However, because this is Laravel Valet for Linux, it’s not so straightforward. One has to first find the correct .conf
file.
Two places to look, depends on SSL or no SSL
You might have to do it in two places, one for all your unsecured sites, and another quite specific site one for SSL protected sites.
cat /etc/nginx/nginx.conf
have these clues in the end:
... text/x-component; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; include /home/user/.valet/Nginx/*; }
Solution
mc -e /home/user/.valet/Nginx/my-site.test
Add Section to Server Block
See 4th line:
server { listen 443 ssl http2; server_name sitename.test www.sitename.test *.sitename.test; client_max_body_size 20M; root /; ...
Then
sudo nginx restart
Reference
Laravel Valet Nginx error 413: Request entity too large – Fix