title: Netbeans Remote XDebug Connection Refused / Waiting for connection, solution not forthcoming
body: <p>Firstly I'll apologise for clogging up the internet with yet another post about Netbeans and XDebuug but after two weeks of trying to get XDebug to work connecting remotely from Windows 7 to my dev machine, I'm left with no alternative. FYI, I've done extensive research into the issue but have run out of quality search results to read.</p>
  
  <p>In summary when trying to attach the debugger I get 'Attaching to 127.0.0.1:9000\r\nConnection refused.', If I try to debug a file through right-click/debug file I get 'Waiting for connection'</p>
  
  <p>In detail here is my XDebug.ini file under /etc/php5/apache2/xdebug.ini:</p>
  
  <pre><code>zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
  
  xdebug.remote_enable = on
  
  xdebug.remote_autostart = off
  xdebug.remote_handler = dbgp
  xdebug.remote_port = 9000
  xdebug.remote_server = localhost
  xdebug.remote_mode = req
  
  xdebug.idekey = netbeans-xdebug
  output_buffering = off
  
  xdebug.remote_log = "/var/log/xdebug.log"
  </code></pre>
  
  <p>My system specs are:</p>
  
  <p>My laptop:</p>
  
  <ul>
  <li>Windows 7  </li>
  <li>Netbeans 7.4  </li>
  <li>Debug browser: Chrome Version 30.0.1599.101 m</li>
  </ul>
  
  <p>My server:</p>
  
  <ul>
  <li>Linux Debian Ubuntu 11.10</li>
  <li>PHP 5.3.6-13ubuntu3.10</li>
  <li>Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
  with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethan [Confirmed running under php_info()]</li>
  </ul>
  
  <p>How i'm trying to connect:</p>
  
  <p>Following <a href="http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/" rel="nofollow">Stuporglues tutorial</a>, I have xdebug and netbeans configured to run on port 9000 (under xdebug.ini and netbeans->tools->options->php->debugging) using a putty connection with port 9000 forwarded as remote under ssh->tunnels (9000/127.0.0.1:9000).</p>
  
  <p>I can see that the Linux server is listening:</p>
  
  <pre><code>james@XXX:/$ netstat -a -n | grep 9000
  tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN
  tcp6       0      0 ::1:9000                :::*                    LISTEN
  </code></pre>
  
  <p>When I try to debug a file I can see that Netbeans is listening on port 9000</p>
  
  <pre><code>netstat -aon
  ...
  TCP    127.0.0.1:9000         127.0.0.1:59691        ESTABLISHED     6744
  </code></pre>
  
  <p>Also, the browser (chrome) opens with the debugging parameter in the address bar correctly:</p>
  
  <p><a href="https://xxxxx.xxx/xxxxx/dMotor1_2PropZ.php?XDEBUG_SESSION_START=netbeans-xdebug" rel="nofollow">https://xxxxx.xxx/xxxxx/dMotor1_2PropZ.php?XDEBUG_SESSION_START=netbeans-xdebug</a></p>
  
  <p>But Netbeans just hangs with 'waiting connection'</p>
  
  <p>Things tried:</p>
  
  <ul>
  <li>I've extensively checked all the applicable firewalls, disabling the windows bundled firewall, and also wiping out iptables and ip6tables on my server, no effect.</li>
  <li>I've tried duplicating the project under http not https in case this was causing issues, no effect</li>
  <li>All types of XDebug.ini settings</li>
  <li>Disabling 'open browser' under project->properties->Run Configuration->Advanced->Debug Url and manually opening the page in chrome with the XDEBUG_SESSION_START parameter correctly appended, no effect</li>
  <li>Under project->properties->Run Configuration->Advanced->Debug Url choosing 'ask every time' with the index.php setting under project->properties->Run Configuration blank, no effect</li>
  <li>Under project->properties->Run Configuration manually appending the XDEBUG_SESSION_START argument as such: netbeans-xdebug, no effect</li>
  <li>Rebooting my computer, restarting Apache and restarting my remote machine endlessly, no effect</li>
  <li>Enabling 'silent debugging mode in chrome', no effect</li>
  <li>Adding the '--remote-debugging-port=9000' option to chromes startup shortcut runpath, no effect</li>
  <li>Installing PHPStorm to see if by I can get any further, no effect</li>
  <li>Using different browsers (have tried Firefox and IE), no effect</li>
  <li>Reinstalled XDebug, after using the wizard to ensure the version is compatible with my PHP release, no effect</li>
  <li>Creating index.php in case this help, no effect</li>
  <li>Setting timezone in php.ini file, no effect</li>
  </ul>
  
  <p>Current theories:</p>
  
  <p>Connection refused? Is there really something blocking the connection? If so, how would I find it? I've tried everything I can think of. Otherwise is this a default error message that's masking a completely different problem?</p>
  
  <p>Further information:</p>
  
  <p>Honestly, its probable I've missed something simple here and have dived far too deep to realise easily, this is the first time I've tried to get XDebug to work on a remote machine and my Linux admin and Netbeans experience is limited.</p>
  
  <p>Even more strangely, I got it working once under the described configuration in my office, then I put my computer on standby and went home, at this point I was also able to run with debug once and then without changing any settings, the problems described above began.</p>
  
  <p>XDebug log file has contained 'could not connect', but currently does not add new content.</p>
  
  <p>Any help would be really appreciated.</p>
  
  <p>Thanks in advance,</p>
  
  <p>James</p>