Magento – How to Solve 502 Bad Gateway error in Nginx Magento 2

magento2nginx

I am getting the error code 502 Bad Gateway in my Magento Installation with the following error in error log

*1 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server: v3.com, request: "GET
/new-arrivals/ HTTP/1.1", upstream:
"fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "v3.com"

How to solve this?

Best Answer

I installed the magento2 when I am trying to open some pages facing 502 nginx issue,

in nginx logs it is showing

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

then solved this issue by modifying this file

/etc/nginx/nginx.conf

add this line of codes inside http{}

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

for more details refer below link

https://bobcares.com/blog/magento-502-bad-gateway/?unapproved=75360&moderation-hash=21aca5cefbcdd86f62c492697cb64954#comment-75360