Magento 2 – Upstream Sent Too Big Header While Reading Response Header from Upstream

magento2magento2.3nginx

We're running Magento 2.3.1 on AWS EC2(t2.medium) Instance with an ELB. Webserver is nginx. Sometimes, we receive the "Upstream sent too big header while reading response header from upstream."-Error in our logs. After researching this issue, I found out that the most popular solution seems to be adjusting the fastcgi buffer size. I've done that without any effect.

To determine the current fastcgi response sizes, I did:

$ awk '($9 ~ /200/) { i++;sum+=$10;max=$10>max?$10:max; } END { printf("Maximum: %d\nAverage: %d\n",max,i?sum/i:0); }' /var/log/nginx/access.log

Maximum: 1613895
Average: 51433

Due to the huge amount of response sizes, I am not sure if the issue is nginx related. My guess is that the current buffer size rules are fine and Magento might has a bug with huge response sizes?

My current buffer sizes are:

fastcgi_pass   fastcgi_backend;
fastcgi_buffers 8 32k;

Best Answer

In my case fresh magento 2.4.1 (nginx on ubuntu) solution (by David Lambauer) worked:

In terminal:

  • cd /etc/nginx/sites-available/
  • ls

Open your nginx config file:

  • code magento24.local.config

Find "fastcgi_buffers"

I change it like that:

        #fastcgi_buffers 1024 4k;
        fastcgi_buffers 16 256k;
        fastcgi_buffer_size 256k;

Save that config file. Restart nginx :

  • sudo service nginx restart
Related Topic