7

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?

4
  • 2
    Hey you can go through below link this might help: Bad Gateway 502 If you find this answer helpful please mark it as solution or upvote thanks. Commented Sep 21, 2018 at 11:55
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – sv3n
    Commented Sep 22, 2018 at 20:44
  • Did you solve your problem? @Pavithra
    – zus
    Commented Jan 17, 2020 at 7:01
  • Please check this link serverfault.com/questions/543999/… May be it helps you with your issue. Commented Feb 10, 2020 at 12:40

4 Answers 4

21

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

2
  • proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; these lines helps thanks man
    – Asad Ullah
    Commented Oct 16, 2020 at 17:23
  • Having this issue in Magento 2.4 . Adding these lines work, thanks Commented Nov 10, 2020 at 19:21
9

Are you using NGINX? It seems there is misconfiguration with your server. Try to add:

http {
  .... your config ...

  fastcgi_buffers 16 16k;
  fastcgi_buffer_size 32k;
}

Restart NGINX and after, the error related to the header size should be solved. Source: https://stackoverflow.com/questions/23844761/upstream-sent-too-big-header-while-reading-response-header-from-upstream

2
  • Awesome. It worked for me. Commented Aug 5, 2020 at 7:25
  • I confirm it workef for me
    – xanka
    Commented Oct 5, 2021 at 10:56
2

I got same type issue for 502 Bad Gateway error in Nginx Magento 2

sudo cat /var/log/nginx/error.log

Content as Below:

FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ReflectionException: Class Magento\Framework\App\ResourceConnection\Proxy does not exist in ClassReader.php:26

magento 2 checkout upstream sent too big header while reading response header from upstream, client: server: d request: "POST /customer/account/loginPost/referer/aHR0cDovL2Rldi5lb25iYXphci5jb20vY2hlY2tvdXQv/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.x-fpm.sock:", host: "dev.eonbazar.com", referrer: " /checkout/" ....etc

I solved my issue update my magento nginx config

Replace #Line with below two line

#fastcgi_buffers 1024 4k; 
fastcgi_buffers 11024 16k;
fastcgi_buffer_size 32k;

enter image description here

0

In my case I am using docker in my local pc. I have have added these two configuration in the nginx.conf and it's working fine.

server {
    //......
    location ~ (index|get|static|report|404|503)\.php$ {
        //........
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        //.......
    }
    //.......
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.