Docker, Laradock, PhpStorm, WSL2, Xdebug configuration

233 Views Asked by At

I've got a problem with connect my Xdebug:

Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9000 (through xdebug.client_host/xdebug.client_port).

I'm running PhpStorm from WSL. Also I'm using Laradock and I don't know how to configure it.

This is my xdebug.ini inside laradock/workspace:

xdebug.remote_host="host.docker.internal"
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"

xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

I'm not sure about xdebug.remote_host.

This is my settings in PhpStorm. Can someone please help me with that I'm trying since Monday to configure it properly.

enter image description here

I'm expecting properly working Xdebug. I tried to add into remote_host my Windows IP, my WSL IP, and host.docker.internal.

1

There are 1 best solutions below

0
Eugene Morozov On

Xdebug cannot connect to PhpStorm because:

  1. You installed Docker as Docker Desktop on Windows
  2. PhpStorm is running in WSL

When you use Docker Desktop, host.docker.internal sends you to the host, the Windows machine.
Since PhpStorm is running in WSL and not on the host, there's nothing listening on the 9000/9003 ports in Windows, and that is why there's no connection.

Instead of host.docker.internal, you can set xdebug.remote_host to the IP of the WSL machine.
For me, setting it to the IP of the eth0 interface worked; you can get it by running ip a in the WSL terminal.

If it still doesn't work after that, it makes sense to check the Xdebug remote log.