无法让 PhpStorm 连接到 WSL 2 中的 Xdebug 运行

Unable to get PhpStorm to connect to Xdebug running in WSL 2

我无法通过以下设置让 PhpStorm 2020.2 与 xdebug 一起工作: WSL2 运行ning Ubuntu 20,安装了 PHP 和 php-xdebug。每当我 运行 启用调试的测试时,它都会显示“未建立连接”。

这是 Xdebug 日志显示的内容:

[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

这仅适用于 CLI,我没有尝试通过 php-fpm 进行连接(因此没有 Apache、nginx 等)。

到目前为止我已经尝试过:

如有任何帮助,我们将不胜感激!

根据: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.

确保 phpstorm.exe 确实被允许(对我来说,专用网络选项未选中)。