Fixing "upstream sent too big header while reading response header from upstream" error in Laravel Valet Nginx

Jul 27, 2020 · Updated: Jul 12, 2021 · by Tim Kamanin

If you're getting a weird 502 Bad Gateway error with Laravel Valet and, most probably Drupal, chances are your Nginx error log is screaming:

upstream sent too big header while reading response header from upstream.

This is because such resource hogs as Drupal send too big payloads when running in development (or any? ;) mode, and as a result, Nginx fails.

But we can fix that. And no, you don't have to throw Drupal away (most probably you should, but finish the project for the client first).

A recipe for sanity:

  1. Go to ~/.config/valet/Nginx directory and create or edit all.conf file.
  2. Add the following contents to it:

    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    fastcgi_busy_buffers_size 32k;

  3. Save the all.conf file.

  4. Restart valet:
    valet restart

And you should be good again! Ha-ha Drupal, eat that, you won't ruin my day this time!

Hey, if you've found this useful, please share the post to help other folks find it:

There's even more:

Subscribe for updates

  • via Twitter: @timonweb
  • old school RSS:
  • or evergreen email ↓ ↓ ↓