Xdebug waiting for connection problem in Netbeans

Just got my new Mac air, and spent hours setting up xdebug to work with the latest Netbeans 7.3.1 on OS X 10.8.4 . I have set up Xdebug on various systems before, including Linux (CentOS, Ubuntu), Windows (XAMPP), and Mac OS, and almost always have issues here and there. This time is no strange either. Netbeans always displays “waiting for connection” every time I clicked the debug button in Netbeans.

The “netstat -nat | grep 9000” command shows port 9000 was connected/disconnected successfully in each try, so it seems that connection was established just fine.

Then I spent hours of time checking firewall setup and playing with all sorts of php.ini parameters. And eventually, I changed the port to 9001 in both php.ini and the Netbeans debugger, and bum it works magically! Sigh.