Issue
Host is Windows. In virtual machine - Ubuntu, and there is a PHP-project in Docker container, adapter is Bridge, access from host through IP 192.168.0.104. In virtual machine project maps upon IP 172.16.100.1 (port 10443). I have opened this project with JetBrains Gateway in host system, having installed PhpStorm into VM. Settings in PhpStorm:
File xdebug.ini:
[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.mode=coverage,debug
xdebug.start_with_request=yes
xdebug.remote_port=9003
xdebug.client_port=9000
xdebug.remote_host=172.16.100.1
xdebug.client_host=localhost
xdebug.discover_client_host=1
xdebug.remote_connect_back = 0
; xdebug.remote_log=/tmp/xdebug.log
; xdebug.log=/tmp/xdebug.log
Same file later:
[xdebug]
zend_extension=xdebug.so
xdebug.mode=coverage,debug
xdebug.client_host=172.16.100.1
xdebug.client_port=9003
By the result of 9003 port analysis I guess, that this port is been listened (called in VM):
$ sudo lsof -i -P -n | grep 9003
ld-linux- 12243 pavel 296u IPv6 262575 0t0 TCP *:9003 (LISTEN)
I have turned Xdebug on and set a breakpoint in the beginning of index.php. Making ssh-tunnel in PowerShell:
ssh -R 9000:localhost:9003 [email protected]
md.mydomain.local
linked in C:\Windows\System32\drivers\etc\hosts
to IP 192.168.0.104
.
Navigating in browser md.mydomain.local:10443
- remote PhpStorm neither stop, nor produce message like "... without being paused"
Solution
With this setup, you don't need an SSH tunnel.
We can also ignore the fact that it's all running in Windows because PhpStorm runs in the VM through Remote Development; so, from the Xdebug point of view, we have a Linux machine that runs a Docker container where you have a web server.
Now, you need to find which hostname the container can use to connect to the VM (and not to the Windows host as you seem to have wanted), and use this hostname as xdebug.client_host
. Usually, host.docker.internal
works okay.
Also, make sure to disable Ignore external connections through unregistered server configurations
until you actually get a debug session in PhpStorm - it's 100% that the PHP | Servers entry that you have created manually is wrong, and thus all incoming sessions will be ignored
Answered By - Eugene Morozov Answer Checked By - David Goodson (WPSolving Volunteer)