WSL2 Xdebug PhpStorm Time-out 连接到客户端

WSL2 Xdebug PhpStorm Time-out connecting to client

我知道这个问题已经被问过很多次了,但我尝试了 20 种其他解决方案并花了一整天,但似乎没有任何效果。

我在 Ubuntu 20.04 上安装了 WSL2 运行 PHP 7.4 + Xdebug 2.9.2,并在新的 Windows 11.

上使用了 PhpStorm 2021.2

php.ini

zend_extension="/usr/lib/php/20190902/xdebug.so"
xdebug.remote_enable=1
xdebug.start_with_request=trigger
xdebug.discover_client_host=no
xdebug.idekey=PHPSTORM
xdebug.remote_port=9003
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.remote_host=172.19.144.1

日志

[29220] Log opened at 2022-01-10 18:54:56
[29220] I: Connecting to configured address/port: 172.19.144.1:9003.
[29220] E: Time-out connecting to client (Waited: 200 ms). :-(
[29220] Log closed at 2022-01-10 18:54:56

$ cat /etc/resolv.conf // nameserver 172.19.144.1

这是一个简单的网络问题,它是 Public 网络而不是私有网络,因此端口 9003 被阻止,即使存在防火墙规则(包括 Public.. .).