:::: MENU ::::

HOWTO – configure Netbeans PHP debugging for a remote server, over a SSH tunnel

Having tripped myself up on multiple occasions setting this up, I’m recording these config steps here for future-me.

Scenario:  You have a PHP site running on a remote [Ubuntu 12.04] server, and want to connect your local IDE [Netbeans] to the Xdebug running on that server over a SSH tunnel.

  1. apt-get install php5-xdebug
  2. vi /etc/php5/apache2/conf.d/xdebug.ini
  3. restart apache2
  4. Create remote->local SSH tunnel ssh -R 9000: yourname@yourserver.com
  5. Launch Netbeans debugger

The key is that your Netbeans IDE acts as the server in this scenario, listening for incoming connections to port 9000 from the remote server’s XDebug.  Thus the tunnel must be from the remote port to your local port, not the other way around.

Some helpful debugging technques

Start ssh with -vv for debugging output

netstat -an | grep 9000

should show something like:

tcp 0 0* LISTEN
tcp6 0 0 ::1:9000 :::* LISTEN


  • Reply Justin |

    Is it a way to remote debug with local (windows platform) and remote (Ubuntu 12.04)?

    Remote debug does not work on Ubuntu 12.04 but it was working on Ubuntu 10.04

    • Reply mrdavidlaing |

      These instructions are for a local Mac OS, and a remote Ubuntu 12.04 server.

      For Windows, you should be able to create the tunnel using a SSH client like Putty.

  • Reply Jared B |

    Thanks for the post, it saved me a lot of time and headache trying to figure out if it could be done. I configured my remote Ubuntu 10 development server to connect back to my Windows workstation running Netbeans over a Putty SSH tunnel for PHP debugging.

  • Reply Tahir |

    Thank you very much for the post. everything worked like a charm. Its still valid for Ubuntu 14.04

So, what do you think ?