'Xdebug don't catch breakpoints in PhpStorm

I configured Xdebug according to this guide

It`s resulting xdebug_config:

zend_extension=xdebug
xdebug.remote_port=9004
xdebug.remote_host=172.24.240.47
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_log=/var/www/html/xdebug.log

In PhpStorm, I registered port 9004 in the Xdebug menu

It`s xdebug log:

[20] Log opened at 2022-03-23 10:29:32
[20] I: Connecting to configured address/port: 172.24.240.47:9004.
[20] I: Connected to client. :-)
[20] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/index.php" language="PHP" xdebug:language_version="7.2.34" protocol_version="1.0" appid="20" idekey="16813"><engine version="2.7.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[20]
[20] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[20]
[20] Log closed at 2022-03-23 10:29:32

But breakpoint does not work :(

if I use xdebug3, i catch next error:

[17] Log opened at 2022-03-23 12:36:17.689724
[17] [Step Debug] INFO: Checking remote connect back address.
[17] [Step Debug] INFO: Checking header 'HTTP_X_FORWARDED_FOR'.
[17] [Step Debug] INFO: Checking header 'REMOTE_ADDR'.
[17] [Step Debug] INFO: Client host discovered through HTTP header, connecting to 172.25.0.1:9003.
[17] [Step Debug] WARN: Creating socket for '172.25.0.1:9003', poll success, but error: Operation now in progress (29).
[17] [Step Debug] WARN: Could not connect to client host discovered through HTTP headers, connecting to configured address/port: 172.24.240.47:9003. :-|
[17] [Step Debug] WARN: Creating socket for '172.24.240.47:9003', poll success, but error: Operation now in progress (29).
[17] [Step Debug] ERR: Could not connect to debugging client. Tried: 172.25.0.1:9003 (from REMOTE_ADDR HTTP header), 172.24.240.47:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
[17] Log closed at 2022-03-23 12:36:17.691381

I tried to share port in docker-compose file

ports:
  - 80:80
  - 9009:9009

And log now

[19] Log opened at 2022-03-23 15:52:45.549575
[19] [Step Debug] INFO: Checking remote connect back address.
[19] [Step Debug] INFO: Checking header 'HTTP_X_FORWARDED_FOR'.
[19] [Step Debug] INFO: Checking header 'REMOTE_ADDR'.
[19] [Step Debug] INFO: Client host discovered through HTTP header, connecting to 172.26.0.1:9009.
[19] [Step Debug] INFO: Connected to debugging client: 172.26.0.1:9009 (from REMOTE_ADDR HTTP header). :-)
[19] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/index.php" language="PHP" xdebug:language_version="7.2.34" protocol_version="1.0" appid="19"><engine version="3.1.3"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>

[19] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[19] [Step Debug] WARN: 2022-03-23 15:52:45.554242: There was a problem sending 179 bytes on socket 11: Broken pipe.
[19] Log closed at 2022-03-23 15:52:45.554442


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source