Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans Xdebug Vagrant connection timeout

I'm trying to get xdebug working for PHP with Netbeans connecting to a Vagrant configured VM (setup with PuPHPet if that matters)

I have these php.ini settings on my VM:

[XDEBUG]
xdebug.remote_connect_back=1
xdebug.default_enable=1
xdebug.remote_autostart=0
xdebug.max_nesting_level=256
xdebug.remote_enable=1
xdebug.remote_log=/tmp/php5-xdebug.log
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.idekey=netbeans-xdebug

Netbeans has the path mapping correct and set to run as local website. It correctly launches a browser with the GET variable to start debugging. My Windows Firewall allows netbeans and I added a rule to allow everything from my VM IP to my local IP (both the 192.168.56.x addresses, so it's the correct subnet).

From my VM I can ping my host OS fine. But in the xdebug log, I just see:

Log opened at 2014-08-23 17:43:28
I: Checking remote connect back address.
I: Remote address found, connecting to 192.168.56.1:9000.
E: Time-out connecting to client. :-(
Log closed at 2014-08-23 17:43:28

On my host OS, I've tried netstat and verified that Netbeans is listening on port 9000. I removed port forwarding on 9000 in Virtualbox because I've read that I don't need that (initially I had it but Netbeans complained that something else was listening on 9000).

I've realized that php-fpm also uses port 9000, so I've tried 9001 (in the ini with a php-fpm restart, and in the IDE, also verified IDE is listening on 9001 now). Same results:

I: Checking remote connect back address.
I: Remote address found, connecting to 192.168.56.1:9001.
E: Time-out connecting to client. :-(
Log closed at 2014-08-23 18:11:59

So now I've read everything and I'm stuck here. Any ideas?

like image 460
Matt Avatar asked Aug 23 '14 18:08

Matt


1 Answers

As I was posting, I found the answer:

$ netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.0.2.0        *               255.255.255.0   U         0 0          0 eth0
192.168.56.0    *               255.255.255.0   U         0 0          0 eth1
link-local      *               255.255.0.0     U         0 0          0 eth0
link-local      *               255.255.0.0     U         0 0          0 eth1
default         10.0.2.2        0.0.0.0         UG        0 0          0 eth0

Notice the last line. So I changed:

xdebug.remote_connect_back=1

to

xdebug.remote_host=10.0.2.2

And it worked immediately after a php-fpm restart!

like image 160
Matt Avatar answered Sep 30 '22 15:09

Matt