XDebug from host to Vagrant VM?

Hi, this case is similar to this one  and I tried a few of the solutions, but my debug configuration for the VM does not even get started. I have tried things on my Intellij Idea 11.1, and a couple of trials for PHPstorm 6 and Intellij 12 to no avail. Here is my scenario:

- Vagrant precise32 VM (see vagrantup.com)
- Configured a forwarded port from guest 80 to host 4567 -- This is the vagrant default port mapping for http, and it does work fine.
- Configured a forwarded port from guest 9000 (default xdebug port) to a specific host port -- tried 4568, 33234, 9000
- Created a Web Application debug configuration, created Web server config that points to port 4567.

Once all the above is done, I hit debug and I get the following odd behavior:

- In both Intellij editors I get "Error running debugger port NNNN is busy" and the session cannot even start. This happens independently of whether I choose any of the above three ports (4568, 33234, 9000)
- In PhpStorm, I get no message, the debugger starts, but breakpoints are not hit.

Troubleshooting steps so far, to no avail:

- Tried different ports, up to and including mapping the guest 9000 to host 9000, so no need to mess with Project Settings / PHP / Xdebug.
- Created tcp/udp firewall rules on the host to open up passage for all the above ports. -- Still, see no point in this as the VM is using a local port mapped.
- Turned off firewall on host.
- Made sure that VM is not running any firewall, by verifying that there are no iptables rules defined -- Note that both ssh / http work fine.
- Tried a couple of the solutions listed on the above thread, but all to no avail. I do believe that likely the vagrant VM because it is using port mapping behaves differently than the scenario described in the thread I listed.

Anyhow, any help would be appreciated.


Hi there,

I have not worked with vagrant myself, so cannot give you 100% correct advice.

In any case, please check these links -- maybe they will help you to notice what you possibly may have missed:

As for debugging approach, I always recomment this manual/article -- have a look in case you have not seen it yet: http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm


Thanks Andriy, the first link clued me into the problem and the solution which consisted of two fixes:

  1. There is no need to do port mapping in the vagrant file: This is because the initiator of the debugging session is XDebug running on the vagrant box. As far as the local phpstorm/intellij waiting for the debugger connection, it is just a remote server and so I needed to do some path mappings once the debugger connected, but all is fine.
  2. I needed to set the xdebug.remote_host to the default routing gateway of the vagrant guest: The point here is that the wrapper virtualbox NAT layer presents itself to the guest as a remote machine on the same subnet, in this case my host was at, which must be the default for Virtualbox. By the way this is the address also reported by $_SERVER['REMOTE_ADDR'].

Once the above two fixes were put in place, things worked on both PhpStorm and Intellij Idea.

My xdebug.ini now looks like this:


which is just minorly different than the configuration suggested on this jetbrains configuring xdebug link as it includes the xdebug.remote_host item.

Here are a couple of links that explain the Virtualbox NAT networking and helped me understand the "remoteness" of the NAT:

Thanks again,

Please sign in to leave a comment.