docker-magento: When Xdebug mode is enabled, 502 Bad Gateway error randomly occurs upon page reload

Description I am using the latest installation (2.4.6-p4) on Ubuntu 22.04 with everything set up correctly. Whenever I enable Xdebug mode, the page randomly gets 502 Bad Gateway error after reloading. I also tried purging then re-installing using different methods (auto, manual, existing project) but all instances pose the same issue.

Screencast from 18-03-2024 17:41:05.webm

Another demonstration of how frustrating it can be when adding products to cart. Screencast from 23-03-2024 09:16:24.webm

I can be sure that I did not encounter this issue in older installation.

Steps To Reproduce

  1. Enable Xdebug mode by running command bin/xdebug enable
  2. Keep refreshing any page

Expected Result Without setting any breakpoints, the page should reload without stopping or any problems.

Actual Result Random 502 Bad Gateway error.

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 23 (9 by maintainers)

Most upvoted comments

The same issue with markoshust/magento-nginx:1.24 and php 8.2. My fix: Downgraded xdebug to 3.2.1 . Here manual: https://github.com/markshust/docker-magento/issues/1085#issuecomment-2027061052 Thank you dude @madmytrych

@markshust I’m facing the same issue. New or existing project - doesn’t matter. Once xdebug is enabled, nginx randomly returns in logs Connection reset by peer. Sometimes, in case of admin panel, the page might load but fail to get the data for it. I’ve set up greater values for fastcgi_buffer_size and timeouts, but no luck. Template v2.4.6-p3, MacOS. Please advise.

I also have this issue.

In my case, I get a 502 error immediately after reloading the page (Ctrl +R), without spinning.

BTW, I also have an old build of docker-magento(44.0.0), I haven’t updated it and everything works 😃 so there is an issue in the newest versions of docker-magento.

Alternatively, consider this as a temporary solution until @markshust or the community fixes the problem.

Hey, I’m doing good.

Did you enable Blackfire?

bin/root /etc/init.d/blackfire-agent status

I’m not using Markhust setup anymore, but Warden. Just my best guess.

Hi @YevhenZvieriev , thank you for your clarifying question.

I set up Xdebug correctly and able to stop at any breakpoint.

Only when 502 error randomly shows up, it won’t stop at any breakpoint, solution is I have to reload the page until the error goes away, which is very frustrating when debugging form submit action such as Checkout.