skip to Main Content
Laravel Valet Nginx 502 Errors

Sometimes your WordPress website won’t load properly in Laravel Valet. You keep on getting Laravel Valet Nginx 502 errors. What can be done about it?

Telltale Signs

In your .valet/Log/nginx-error.log  you will see something like:

HTTP/2.0", upstream
2018/07/24 09:18:54 [error] 15573#0: *328 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server:

That means that your Nginx defaults are not good enough to handle the needs of the local setup.

Nginx Configuration Tweaks

To deal with this you can change your Nginx confix under .valet/Nginx/site.test and add the following to the php block:

# 24 july 2018 parameters to avoid Nginx 502 errors
  fastcgi_temp_file_write_size 10m;
  fastcgi_busy_buffers_size 512k;
  fastcgi_buffer_size 512k;
  fastcgi_buffers 16 512k;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_intercept_errors on;
  fastcgi_next_upstream error invalid_header timeout http_500;

source SO pacofelc

Restart Brew Nginx Services

You will then also need to restart Nginx for Valet and you can do this like so:

brew services restart nginx

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top