Remote Xdebug with VirtualBox

I am trying to work with remote debugging. PHP is running in a virtual machine, and I'm trying to debug NetBeans on a host machine.

I followed the instructions here , redirected port 9000 to the Windows 7 firewall and to the VirtualBox network settings, and configured path mappings in NetBeans. My xdebug settings are as follows:

xdebug.remote_enable = On xdebug.remote_connect_back = On xdebug.idekey = "netbeans-xdebug" xdebug.remote_log = /tmp/xdebug.log 

When I load the URL that I want to debug (using the correct ideck), it logs the following:

 I: Checking remote connect back address. I: Remote address found, connecting to 192.168.0.1:9000. I: Connected to client. :-) -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/dev/web/projects/project.com.vm/httpdocs/index.php" language="PHP" protocol_version="1.0" appid="1380" idekey="netbeans-xdebug"> <engine version="2.2.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init> -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response> 

However, NetBeans is waiting for a connection. I have a setting to stop on the first line, except that you have a breakpoint set. The log file will include a "Connected to Client" message, even if NetBeans is not listening.

Any idea what I might be missing?

Thanks.

+9
source share
5 answers

The following worked for me:

 ssh -R 9000:localhost:9000 yourUserName@yourVirtualMachine 

Note the use of the -R flag instead of -L. I had problems using port forwarding to make things work while the ssh tunnel worked fine. Note that you can also do this by running the ssh command from the virtual machine and connecting to the host with the -L flag.

Since I settled on this issue while working with Vagrant, I personally used this command, use the password 'vagrant' when prompted:

 ssh -p 2222 vagrant@127.0.0.1 -R 9000:localhost:9000 
+7
source

My solution to this problem was as follows:

1) Enable port forwarding in the network configuration (using the NAT adapter) I just used port 9000 and the host and guest IP addresses. TCP protocol

2) Configured my xdebug settings: In my case, it was important to set xdebug.remote_host = "Permanent host IP address" Then everything worked fine.

Hope this helps someone out there.

+5
source

I added 4 options for using Xdebug in my projects in a virtual machine:

 xdebug.remote_enable = On xdebug.remote_host = [YOUR_HOST_IP] xdebug.remote_connect_back = On xdebug.remote_autostart = On 

While your debugger is listening, it should break at a breakpoint.

+3
source

The virtual machine must be able to talk to the host machine, and for this to happen, you need to forward 9000 for this. This step is not described in some settings, because it happens in the background.

To do this, run the ssh -L 9000 command: localhost: 9000 yourUserName @youVirtualMachine.

To simplify this, I have the name of the virtual machine in / etc / hosts and in the file ~ / ssh / config.

+1
source

If this is in your log file:

 I: Connected to client. :-) 

This means that Xdebug has successfully established a connection with the IDE.

The IDE (netbeans) simply then disconnects the connection without even trying to send any information. This happens if he does not know what to do with the file name ( file:///home/dev/web/projects/project.com.vm/httpdocs/index.php ) in your example. The reason for this is because you do not have the correct path mapping configured in your IDE.

+1
source

All Articles