问题
I am having trouble getting PhpStorm 2020.2 to work with xdebug with the following setup: WSL2 running Ubuntu 20, with PHP and php-xdebug installed. Whenever I run my tests with debugging enabled it says "Connection was not established.".
This is what the Xdebug log shows:
[5877] Log opened at 2020-08-14 17:20:45
[5877] I: Connecting to configured address/port: 172.18.48.1:9006.
[5877] E: Time-out connecting to client (Waited: 200 ms). :-(
[5877] Log closed at 2020-08-14 17:20:46
This is for CLI only, I'm not trying to connect via php-fpm (so no Apache, nginx, ...).
So far I have tried:
Changing the port to something other than 9000 (portscans also reveal that none of them are in use).
Adding a firewall rule to allow incoming requests as described in https://github.com/microsoft/WSL/issues/4585#issuecomment-610061194 (as well as restarting a couple times after adding the rule)
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
Adding options like
xdebug.remote_enable=1
to the config, but this is being done by PhpStorm anyways when it runs the remote php instance (remote_connect_back
also did not do the trick):[wsl://UBUNTU2004]:php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9006 -dxdebug.remote_host=172.18.48.1 /home/spaceemotion/code/xxxxxx/backend/vendor/phpunit/phpunit/phpunit [rest ommitted]
Any help would be much appreciated!
回答1:
As per: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000436444/comments/360000168070
In Windows Control Panel > Windows Firewall > Allow a program or feature through Windows Firewall you can see a list of software that is allowed to communicate through private and public networks.
Make sure the phpstorm.exe is actually allowed (for me the private network options were unchecked).
来源:https://stackoverflow.com/questions/63417516/unable-to-get-phpstorm-to-connect-to-xdebug-running-in-wsl-2