Setting up debugging with XDebug 3 and WSL2

Tried the steps mentioned in this post and post. However, debugging continues to fail due to the following error: 

Connection was not established. Cannot start debugger session with 'Xdebug 3.0.4'


XDebug Config:

zend_extension=xdebug.so

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_host=192.168.173.130
xdebug.remote_port=9000
xdebug.client_host=192.168.173.130
xdebug.client_port=9000
xdebug.log=/var/log/xdebug.log
#xdebug.discover_client_host=false
xdebug.idekey=PHPSTORM

 

This is a portion of the command executed by PHPStorm when debugging:

Unsure as to why the remote_host is passed as 127.0.0.1

php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 "-d xdebug.remote_host=192.168.173.130" "-d xdebug.client_host=192.168.173.130" "-d xdebug.remote_port=9000" -dxdebug.client_port=9000

 

And this is a portion of the command executed by PHPStorm when running a script/test:

php "-d xdebug.remote_host=192.168.173.130" "-d xdebug.client_host=192.168.173.130" "-d xdebug.remote_port=9000" -dxdebug.client_port=9000

In this case PHPStorm does not automatically pass 127.0.0.1 as remote_host's value and only the values setup in the XDebug options in IDE are passed.

Had uninstalled anti-virus and also disabled the firewall. However, debugging connection fails. Strangely nothing is written to xdebug logs.

System Info

PHPStorm Version: PhpStorm 2020.2.4
Build #PS-202.8194.11, built on November 25, 2020
Licensed to Nikhil Ranka
You have a perpetual fallback license for this version
Subscription is active until May 4, 2022
Runtime version: 11.0.9+11-b944.49 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0

Would be great if you could help in setting this up.

Thanks!

5 comments
Comment actions Permalink

First of all, you're running an old IDE version: 2020.2.4. A series of fixes were released since then both aiming at XDebug 3 & WSL configuration so I would suggest testing this on latest IDE version.

Next, please check if debugging works with "phone" button toggled to "listen":

Also: is your IDE installed on the Windows host or inside WSL?

0
Comment actions Permalink

Ok, Dmitry Tronin thought so. Will update the IDE. Kept myself from updating because most features that I wanted were working as expected. Also noticed that in recent updates some required features were breaking. 

- The phone button is toggled to Listen.

- Using on WIndows. Any benefits to using the IDE on WSL? Would want to be able to run projects on both Windows and WSL. 

Thanks!

0
Comment actions Permalink

Updated the IDE to the latest version 2021.2.2. The debugging now works. Had to additionally set the settings here:

Had not found this in the documentation. Probably my oversight or documentation does not have it. 

When the internet is turned off it stops working. Can you suggest a workaround for the same?

Thanks!

 

0
Comment actions Permalink

Dmitry Tronin Any insights on the above?

0
Comment actions Permalink

1) We don't have WSL-specific instructions for XDebug yet, unfortunately. The options you set in the Interpreter Configuration options could as well be set in a php.ini. Didn't that work for you initially?

2) Regarding the broken debug after turning off the internet. Looks like a firewall issue. Try granting PhpStorm an access at Control Panel\System and Security\Windows Defender Firewall\Allowed apps

1

Please sign in to leave a comment.