Xdebug configuration under X11 forwarding

I have WSL2 + X11 forwarding via X410 enabled (offers WAY better DX than standard setup). The PHP runtime in Docker container(s). Although it all works very well, I'm not able to set-up the Xdebug 3 for the current situation. What's the officially suggested way?

4 comments
Comment actions Permalink

There's no officially suggested way, unfortunately, there are way too many variables. In general, you need to find an IP/hostname that you can use to connect from the container to the Linux host.

I find it useful to create a listener on the host I want to connect to with nc -l 9005 and then telnet hostname 9005 from the container trying to find a hostname that works.
Then, you'll just have to specify this hostname as xdebug.client_host.

Is it Docker Desktop with the WSL2 engine or you've installed Docker in the WSL directly, with `apt`?

0
Comment actions Permalink

Eugene Morozov thanks, great advice. 

The docker backend is the WSL2 one. Nevertheless when I create the listener it occupies the given port on IPv4 and one can telnet from docker container with host.docker.internal which is perfectly fine. At the same time when I start the listener from PHPStorm, it occupies the port on IPv6. Is there a way to configure that?

0
Comment actions Permalink
-Djava.net.preferIPv4Stack=true

does the trick

0
Comment actions Permalink

Yep, for some reason, in WSL, some services start listening on IPv6, PhpStorm included.
Here's a report about it on the WSL tracker: https://github.com/microsoft/WSL/issues/4851
Thank you for sharing your findings!

0

Please sign in to leave a comment.