php - How to properly configure xdebug.client_host for Docker in Linux?

one text

Solution:

Here is one way to set the correct IP address and automatically set it to your configuration files.

  • Make sure your firewall is deactivated between Windows and WSL
# Windows powershell as administrator
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
  • Add this line to your ~/.bashrc in WSL
export host_ip=$(ipconfig.exe | grep 'vEthernet (WSL)' -A4 | cut -d":" -f 2 | tail -n1 | sed -e 's/\s*//g')
  • You can verify your IP with
echo $host_ip

Now you can use your new variable everywhere. eg in .env file`:

XDEBUG_CONFIG="client_host=${host_ip} remote_port=9003 idekey=PHPSTORM"

Source