Cant get xdebug working

I am using PhpStorm for development in Windows 7. I am trying to setup xdebug.
I installed xdebug to server by using pecl.
I added these codes to php.ini



phpinfo() shows Xdebug running.
when i use;

netstat -aon | more

on cmd I can see that its listining in port 9001

 TCP               LISTENING       4908

But Xdebug can not connect to PhpStorm
xdebug.log shows that it can not connect to my ip:port

Log opened at 2013-05-02 17:20:55  
I: Connecting to configured address/port: 212.2XX.179.83:9001.
E: Could not connect to client. :-(
Log closed at 2013-05-02 17:20:58

Log opened at 2013-05-02 17:20:58
I: Connecting to configured address/port: 212.2XX.179.83:9001.
E: Could not connect to client. :-(
Log closed at 2013-05-02 17:21:16

Log opened at 2013-05-02 17:21:16
I: Connecting to configured address/port: 212.2XX.179.83:9001.
E: Could not connect to client. :-(
Log closed at 2013-05-02 17:21:19

I runned;

nc -v 212.2XX.179.83 9001

on the server and it answers

nc: connect to 212.2XX.179.83 port 9001 (tcp) failed: Connection timed out

I am working on this for 3 days and can not find a solution.
Any help about debugging why server can not connect to ip would be great. Thanks

Comment actions Permalink

Hi there,

Please show the screenshot with the port forwarding settings of your router as well as "Settings | PHP | Debug" from PhpStorm.

Comment actions Permalink

As far as I'm aware the port forwarding on router is NOT configured properly.

I still have no idea why you keep using your EXTERNAL IP when page clearly says (on the top .. and then again in the middle) that you have to enter your LOCAL / LAN IP address ( -- at the end of the day that's where all incoming connections on that/those ports will be forwarded to -- to your computer behind the router.

Just find out LAN IP address of your computer and use it there (see output of ipconfig). For example:
Let me know about outcome.

Comment actions Permalink

If CanYouSeeMe and alike can see you on that port ... but xdebug still does not work .. then I only have these ideas/checklist:

1) Make sure that IP address you use is up to date / correct (CanYouSeeMecan use your current IP from browser while manually provided IP on your server may be out of date)
In one place you were using

(old one) on another -- 151.XXX.235.47 --- which one is correct now?

2) Make sure that PhpStorm listens for debug connection at that time ("Run | Start Listen PHP Debug Connection" should be enabled -- the easiest way). I always recommend this article:

3) I never worked with nc -- always used telnet for such purpose. But I guess they both do the same thing in this particular regard.

I have tried telnet to your  IP (I believe it is yours) and it seems to connect fine (running from Windows):

open 9001

I do see the same response when I attempt to connect to locally running PhpStorm when it listens for connection.

Configuring my PHP to connect to your IP:

Log opened at 2013-05-04 11:11:11
I: Connecting to configured address/port:
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" fileuri="file:///E:/Projects/web/_idetest/test.php" language="PHP" protocol_version="1.0" appid="5716" idekey="phpStorm"><engine version="2.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[]]></url><copyright><![CDATA[Copyright (c) 2002-2013 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="step_into" transaction_id="4" status="break" reason="ok"><xdebug:message filename="file:///E:/Projects/web/_idetest/test.php" lineno="2"></xdebug:message></response>

<- run -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="run" transaction_id="5" status="stopping" reason="ok"></response>

<- stop -i 6
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="" command="stop" transaction_id="6" status="stopped" reason="ok"></response>

Log closed at 2013-05-04 11:11:12

Based on this I assume that it does work fine from xdebug side -- possibly what is left is some configuration from PhpStorm side somewhere. I may only refer to the same article again and suggest testing this on very basic and simple script (few very simple lines; one command per line) until you make it work -- after that you can move to real project. Something like this:

$a = 15;
$b = 5;
$c = $a + $b;
echo "{$a} + {$b} = {$c}\n";

4) Make sure that you have breakpoints set on reachable statements (on some lines xdebug simply cannot break, for example: ). Alternatively use xdebug_break(); to force break from the code.


Please sign in to leave a comment.