Cannot connect to xdebug over virtual network – Vagrant Virtualbox

apache-2.2puppetvagrantvirtualboxxdebug

I'm trying to set up a development box using Virtualbox / Vagrant / Puppet with the intention of eventually provisioning all my machines up to production. However this is stopping me going forward at the moment. I've installed ubuntu lucid over windows 7.

When trying to connect to xdebug by starting a debugging session in eclipse, it hangs at 57% (common in eclipse when it cannot communicate with xdebug). Here is my xdebug.ini and the settings here are appearing in phpinfo().

xdebug.remote_enable=On
xdebug.remote_handler=dbgp
xdebug.remote_host=192.168.56.1
xdebug.remote_port=9000

I'm now wondering if it's an issue with port forwarding? If eclipse is looking on port 9000, will it find port 9000 on a virtual machine?

Any help would be greatly appreciated!

Best Answer

I have found this to be a problem of many network interfaces. When I set up xdebug.remote_host to the IP adress my local machine (the one running virtualbox) uses to access the internet, the debugging works just fine. This does not mean the external IP, but the one my machine has in the local LAN (from wich the internet is accessed) Setting the IP adress to the one being paired with the host only adapter (e.g. 192.168.56.1) doesn't work. However: I got the whole thing running at one time with the host only adapter. although I can - for the life of me - not figure out what it was that did the trick. only different thing was, all other connections on the machine were disabled. But I can not reproduce the state I had..

Edit: Ok, I've found out what the problem was: The problem is a Windows problem (what else?). Windows seems to handle the Network Adapters like real adapters and hence inklude them in firewall issues. You need to tell Windows, that all "VirtualBox Host-Only Ethernet Adapter" Devices are not real devices.

To do so you have to make some minor changes to the registry: Open regedit and navigate to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}

In this key you will find all kind of adapters your system uses. Find those Keys that have a property 'DriverDesc' with the value 'VirtualBox Host-Only Ethernet Adapter' and add a new DWord property named '*NdisDeviceType' with the value 1. restart your machine and that was it.

Please note that from that point on all your VirtualBox Host-Only Ethernet Adapters will not show in Network and Sharing Center anymore!

Once this is done XDebug will even work with the xdebug.remote_connect_back = 1 parameter, which it did not do before!