Fix Upstream Sent too big header Error

NGINX: How to Fix Upstream Sent too big header Error

When you run NGINX proxy configuration you may get “Upstream Sent Too Big Header” error. In this article, we will look at how to fix this error.


NGINX: How to Fix Upstream Sent too big header Error

Here are the steps to fix upstream sent too big header error in NGINX.

Before NGINX sends response, it buffers the request made from upstream. However, there are limited buffers available in NGINX, by default. If the HTTP headers of those requests contain a lot of data then you will see this error.

This error occurs when you use proxy_pass directive. For example, you may have the following NGINX proxy configuration.

server {
  listen        80;
  server_name   example.com;

  location / {
    proxy_pass       http://upstream;
    ...
  }
}

To fix this problem, you need to increase proxy_buffer_size configuration. You may add it to a specific location block, if you get this error only for specific URLs. For example,

server {
  listen        80;
  server_name   example.com;

  location / {
    proxy_pass       http://upstream;
    ...
    proxy_buffer_size          128k;
    proxy_buffers              4 256k;
    proxy_busy_buffers_size    256k;
  }
}

The above lines increase NGINX proxy buffer from 4KB to 128KB.

You may add it to server block, if you get this error for all URLs.

server {
  listen        80;
  server_name   example.com;

  proxy_buffer_size          128k;
  proxy_buffers              4 256k;
  proxy_busy_buffers_size    256k;

  location / {
    proxy_pass       http://upstream;
    ...
  }
}

Save and close the file. Restart NGINX server to apply changes.

$ sudo service nginx restart

Leave a Reply

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