No breakpoints when using xdebug in vscode to a apache server running in virtualbox

1 day ago 2
ARTICLE AD BOX

Currently trying to get breakpoints working in vscode to a php server running in virtual box.

My VS Code launch is as follows

{ "name": "Listen for Xdebug", "type": "php", "request": "launch", "port": 9003, "pathMappings": { "/home/ubuntu/app/": "Z:\\", }, "log": true },

Virutal box is running a ubuntu image with apache and php7.

I'm using a samba share to mount the app folder to my Z drive, however the apache config is using a symlink to said folder on the machine. box is setup with a nat connection and forwarding port 9003. have xdebug 2 on the apache server and verified in phpinfo() its installed.

xdebug config is:

zend_extension=xdebug.so xdebug.remote_autostart = 1 xdebug.remote_enable = 1 xdebug.remote_port = 9003 xdebug.remote_log = /var/log/xdebug.log xdebug.remote_connect_back = 1 xdebug.remote_handler = dbgp xdebug.idekey = vsc xdebug.remote_mode = req

When I launch the site in chrome breakpoints dont appear to be hit. Vs code log doesnt seem to output anything relevant. Checking the xdebug log on the server I can atleast see that its making a connection.

Log opened at 2026-02-02 16:12:31 I: Checking remote connect back address. I: Checking header 'HTTP_X_FORWARDED_FOR'. I: Checking header 'REMOTE_ADDR'. I: Remote address found, connecting to 10.0.2.2:9003. I: Connected to client. :-) -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/ubuntu/app/mc_app/JSON_Controller.php" language="PHP" xdebug:language_version="7.2.1-1ubuntu2" protocol_version="1.0" appid="14775" idekey="vsc"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init> -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response> Log closed at 2026-02-02 16:12:32

Any additional help would be appreciated. Not quite sure if its the NAT causing issues or something with the configuration

EDIT: After further testing, I am getting breakpoints if I set the remote_host to local host and run VS code inside the box.

Read Entire Article