phpdockerphpstormxdebug

PhpStorm inserts wrong client_host IP when trying to run debug session


PHP interpreter runs in docker container, Xdebug configuration is

zend_extension=xdebug.so

[xdebug]
xdebug.mode=debug
xdebug.idekey=Docker
xdebug.discover_client_host=on
xdebug.client_host=host.docker.internal
xdebug.client_port=9011
xdebug.cli_color=1

When I run debugging session in tests, PhpStorm runs the execution string starting with

[docker-compose://[/home/Projects/service/docker-compose.yaml]:php/]:php -dxdebug.mode=debug -dxdebug.client_port=9011 -dxdebug.client_host=172.24.0.83 ...

Notice -dxdebug.client_host=172.24.0.83 part... But host.docker.internal has another IP:

$ docker-compose exec php ping host.docker.internal
PING host.docker.internal (172.17.0.1): 56 data bytes
64 bytes from 172.17.0.1: seq=0 ttl=64 time=0.053 ms

And of course it failed to start debug session. I didn't find any occurrence of this strange IP 172.24.0.83 anywhere in the project nor in the PhpStorm setting. How can I get rid of this obviously non-working condition in PhpStorm?


Solution

  • Problem solved. There is some steps to fix xdebug in cases like mine.

    As @LazyOne mentioned, you can disable automatic passing of Xdebug CLI configuration option in Settings/Preferences | PHP | Debug in a Settings section by unchecking Pass required configuration options through command line (still need to enable debug extension manually) checkbox.

    As @Derick mentioned, it is better to use your actual IP address of the machine (smth like 192.168.1.200) for xdebug.client_host. That is working for rootless docker also.