Howto check xdebug installation

Petr in one of his recent entries mentions how to install xdebug in Ubuntu. I would like to add a very simple test how to verify that xdebug is properly installed on any supported platform. Naturally the most straightforward test would be to use debugger in NetBeans PHP IDE. Definitely, but maybe you haven't installed NetBeans yet, so I've decided for different approach - just write a very lightweight test listening to a connection on port 9000 (default one for xdebug). Which language to choose? Not much important but why not PHP? So, here we go:

screesnhot: verification code testing proper installation of xdebug

Now if we have a code (let's choose filename like "dbgtest.php") we can use it. Two simply steps should be enough to verify that xdebug was properly installed:

  1. run the code from command line (e.g. /usr/bin/php dbgtest.php)
  2. start debug session for arbitrary file from within a browser window (e.g. http://localhost/index.php?XDEBUG_SESSION_START=mysession)
If xdebug is properly installed then script started in step 1. should print message like "connection established: Resource id #5". If no message is printed and the script is still running, then xdebug isn't installed properly or uses different port or whatever else. So, kill the running process and investigate where the problem is, but this is the other story.


Nice. Thanks. I look forward to seeing how to configure NetBeans to use Xdebug.

For those who are too lazy to type out the code...

$address = '';
$port = 9000;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Unable to bind');
$client = socket_accept($sock);
echo "connection established: $client";

Posted by Courtney Miles on July 15, 2008 at 07:19 PM CEST #

Thanks, for those on unix who would like to save even more time: socket -s 9000

Posted by Radek on July 16, 2008 at 02:22 AM CEST #

at the first i apologize for my English writing
my problem is when i start to debugging, my IE want to connect to netbeans javascript debugger web page and in the bottom of my ide show "waiting for connection (netbeans-xdebug)" and its never end.
whats the problem?

Posted by reza on September 11, 2008 at 02:18 AM CEST #

Hi Reza,

if I understand correctly, you want to debug JavaScript not the php code. I'm right? If yes, go to the project properties and switch off the Debug Server Side PHP option in Debug category.

If you want to debug PHP, you have to have installed Xdebugger properly.

Posted by Petr on September 11, 2008 at 10:26 AM CEST #

I have just installed NetBeans for PHP, after some less than ideal experience with PHPEdit.

I have not been able to debug anything however:
The debug process is said to be "waiting for connection (netbeans-xdebug)" and 'its never end' for me also.

Yet PHPEdit is using XDebug mostly without issue on port 9000.

Additionaly if I use your code above and enter the URL http://localhost/xdebug_test.php?XDEBUG_SESSION_START=mysession
In IE I get http 500 internal server error, In firefox just blank output - any comments welcome.

Windows xp sp2
Netbeans (Build 200804221056)
Java: 1.6.0_07; Java HotSpot(TM) Client VM 10.0-b23
apache 2.2.6
php: 5.5.5
xdebug php_xdebug-2.0.2-5.2.5.dll

phpinfor reports:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Xdebug v2.0.2, Copyright (c) 2002-2007, by Derick Rethans

Posted by Andrew Seabrook on September 22, 2008 at 07:05 AM CEST #

Hi Andrew,

the Build 200804221056 is really old. It was a technical preview. I suggest to you to try a latest development build, which is much better.

Regarding the debugging. Is the property xdebug.remote_enable switch on?


Posted by Petr on September 22, 2008 at 07:57 AM CEST #

I run into some problems with config xdebug for using with netbeans. The solution was to remove every '' from php.ini and load xdebug with 'zend_extension=/compleate/phat/to/'. After that, in the output of phpinfo() ther should not stand 'XDEBUG NOT LOADED AS ZEND EXTENSION'.
Maybe this is helping some other to.

Posted by Sam on October 30, 2008 at 03:40 AM CET #

Thanks Sam, it can be useful for other people.


Posted by Petr on November 02, 2008 at 07:10 AM CET #

Hi Petr, I run into problem with the xdebug for my PHP5 and Netbeans 6.5. I have followed all the instruction that I could find on the net such as download xdebug v2.0.3...put it in the ext folder under PHP dir...change the php.ini...with no help. When I check my php version on command line using php -v, it says i have Zend Engine v2.2.0 ...with Xdebug v2.0.3. I also had fatal error when trying to run your above code. The error was "Call to undefine function socket_create()". Do you have any idea?
Thank you

Posted by Tuyen Truong on December 03, 2008 at 07:39 PM CET #

Hi Tuyen,

there can be more problems. Which OS do you use? Did you disabled the Zend debugger? How did you register the xdebug? As a zend_extension? Go through this discussion. Let me know, if you are success.


Posted by Petr on December 04, 2008 at 05:54 PM CET #

Hi Petr,
Thank you for your answer. The machine I use has win Vista. I search the PHP init file and I don't think I have Zend debugger. If this is not the right place to search for it, please show me how.
I register xdebugger by adding in the init file these lines:

I am new to Netbeans so please bear with me if my question or answer make no sense to you.
Thank you.

Posted by Tuyen Truong on December 10, 2008 at 04:13 PM CET #

Hi, Petr,
I have very similar problems with NetBeans 6.5 PHP-pack and xdebug.
If I want to debug anything at the local server, the debugger ignores all the breakpoints, although the process is running (the connection ocured).
The debugger is properly configured, since it runs perfectly well, if I specify php-cgi as the php-interpreter in the run configuration.
And PHPDesigner (a very fast PHP editor) uses xdebug locally without problems.
I checked Firefox, Opera and IE7 as browsers - breakpoints are ignored, the debugger runs through. Shutting down the firewall produces no effect.
I have PHP 2.5.2 as a part of XAMPP on Vista with Apache 2-ts; in fact I had to leave_ts in the confuguration line for xdebug in php.ini and curiously enough, I had to uncomment the 'extension=php_xdebug.dll'
line, otherwise the apache server permanently crashed.
I'd guess the problem is with NetBeans?
Though I can debug with php.cgi, in principle, it feels annoying ;). I hope this annoyance will soon go.


Posted by Anatoli Strigin on December 10, 2008 at 04:47 PM CET #

Sorry, the PHP version number is 5.2.5, of course.

Posted by Anatoli Strigin on December 10, 2008 at 04:49 PM CET #

Hi Tuyen, Anatoli,

I don't have many experience on windows. I suggest to go through this topic . You can find here some hints.

To Tuyen: send to the html output from phpinfo(), which you get through the Apache.

To Anatoli: in your case it can be something different. Which application do you want to debug? Is it a framework based?


Posted by Petr on December 11, 2008 at 03:14 PM CET #

Sorry, Petr, for the long answer delay.
The answer is: no, it is not. It is a simple script embedded in the usual html tags.
$sum_of_factorials = calculate_sum_of_factorials ($m, $n);
echo "The sum of factorials of the entered integers is " . $sum_of_factorials;

function calculate_sum_of_factorials ($argument1, $argument2) {
$factorial1 = calculate_factorial ($argument1);
$factorial2 = calculate_factorial ($argument2);
$result = calculate_sum ($factorial1, $factorial2);
return $result;

function calculate_factorial ($argument) {
$factorial_result = 1;
for ($i=1; $i<=$argument; $i++) {
$factorial_result = $factorial_result\*$i;
return $factorial_result;

function calculate_sum ($argument1, $argument2) {
return $argument1 + $argument2;
This is the only file in the project (a test, as it were).

Posted by Anatoli Strigin on January 06, 2009 at 02:35 PM CET #

To Anatoli: The xdebug.dll has to be registered as zend_extension. Crashing Apache on Vista is known problem and sometime can help increase the memory for executing php scripts. Look at this topic . You can find there a solution.

Posted by Petr on January 07, 2009 at 04:11 AM CET #

I thought I was a competent \*nix admin but I have no idea what Radek means by "socket -s 9000"!

Anyway, I still haven't resolved my issue but for those who would like a little more feedback than the originally posted code I offer this small enhancement:

$address = '';
$port = 9000;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Error: ' . socket_strerror(socket_last_error()));
$client = socket_accept($sock);
echo "connection established: $client";

BTW, my error is "Address already in use" but netstat shows nothing listening on 9000 locally. Hmmm...

Posted by Bill on April 04, 2009 at 03:54 PM CEST #

Hello! Xdebug is properly installed and as loading fine by Apache together with zend. Although I definitely have a problem configuring it to work with remote machine, which in turn has dynamic ip.
I put as xdebug.remote_host. Ports and firewalls are properly setup at both ends.
xdebug.remote_handler = gdbp and I also start Netbeans with -J-Dorg.netbeans.modules.php.dbgp.level=400.
No change. Browser (Firefox with netbeans extension) starts and loads page as usual. The only sign of xdebug presence is colored var_dump. Xdebug makes no dump output in browser as well.

Can somebody help?

Posted by Antony on May 30, 2009 at 06:55 AM CEST #

I'm having the same problems as Antony and others... can't connect to the debugger. The dbgtest.php scripts times out. But I do see the coloured var_dump()'s...

Posted by Leon Bogaert on July 15, 2009 at 08:52 AM CEST #

So am I.
The test code and socket -s 9000 returns Already in use error.
This Ubuntu 9.04 and xampp 1.7.1 running in irtualBox 3.0.2.
foiled at the very last setup step !!

Anyone sort this issue?

Posted by John R on July 17, 2009 at 09:58 AM CEST #

Hi all,
I've worked out what is happening...

i) as a new user to NetBeans, I didn't realise that "Stop at First Line" is defaulted to Yes, and appears in Options:PHP section. IMHM that's in the wrong place, and should be on the Debug menu

ii) the test code is wrong. I expect that once the program is run, a connection to port 9000 is made by NetBeans (acting as a debug client), so when the test code runs in the PHP page being debugged it tries to open another - which it can't.

Wasted a few hours, but taught me a bit more how PHP debugging works.

Very impressed with NetBeans, by the way. Congratulations and thanks to the team that develops it.


Posted by John R on July 18, 2009 at 10:20 AM CEST #

I got the following error from log file. Installation is done on wamp server.

Fatal error: Call to undefined function socket_create()

How can I check the installation now?

Posted by Tejas Sali on August 28, 2009 at 01:46 AM CEST #

Hi John,

I had the same problem of undefined socket_create(). This is most probably due to the fact that sockets are disabled in php regular installation(in WAMP as my case was). You just have to go to your php.ini file(remember there are 2 php.ini files in case of wamp) and uncomment extension=php_sockets.dll

This should make socket_create as a recognized function call for php engine.

Posted by Sumit on August 28, 2009 at 10:04 AM CEST #

Sorry for the confusion. My message was directed to Tejas not John....

Posted by Sumit on August 28, 2009 at 10:05 AM CEST #

I'm running Vista with the latest XAMPP 2.5.8 (which has PHP version 5.3.0). I installed the latest XDEBUG (matching for VC6 and threaded), and modified php.ini accordingly.

When I load a page with phpinfo(), xdebug does not appear on the page.

I tried the test you have, and it hangs when trying "socket_accept", and says "Transferring data from localhost..."

Do you know what the problem is?

Posted by Quinn on August 28, 2009 at 03:56 PM CEST #

It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.

Posted by links of london on October 29, 2009 at 08:07 PM CET #

Hello Radek Matous,

Thank you for the script. Unfortunately I have problems to verify my xdebug installation. After running your script no message was printed in the browser window. Could you suggest the steps, how to troubleshoot this problem.

Thank you

Here is my configuration:
Wamp server verxion 2.0h
I downloaded and installed php_xdebug-2.0.5-5.2.dll

My Php.ini

Posted by Steve Smith on November 17, 2009 at 02:35 AM CET #

Thanks for posting this handy check... new to NetBeans and loving it more by the minute! I'm keeping the file in my little tool stash.

Posted by Liz on December 10, 2009 at 01:34 PM CET #

I'm trying to set up php with Netbeans 6.5 using the WAMP stack, as per guidelines to check whether xdebug is installed and working properly, to my misfortune, no message is printed and the script remains running. I am stuck on this for quite a while now trying to investigate the issue. From what little I've explored, xdebug module is recognized by the WAMP, phpinfo() does list the xdebug extension.

Trying to debug from netbeans, results in indefinite wait, for xdebug connection. The script to test xdebug specified above also runs indefinitely without any messages displayed, Socket extension though has been activated.
The Apache log file gives a warning "PHP Warning: Xdebug MUST be loaded as a Zend extension in Unknown on line 0", googled through this nothing substantial or really helpful which would rescue me out of this problem

Am I missing on something which is very silly and going under the nose un-noticed. or are there issues with respect to the php xdebug and netbeans versions. Any pointers on this will be appreciated.

Posted by zarrar on February 11, 2010 at 12:59 PM CET #

I'm getting this error when I visit my test page @ http://localhost:8080/test_xdebug.php?XDEBUG_SESSION_START=mysession

"Fatal error: Call to undefined function socket_create() in C:\\wamp\\www\\test_xdebug.php on line 4"

Any idea what's wrong here?

Posted by Roger on April 07, 2010 at 01:05 PM CEST #

Never mind. Fixed it. I needed to uncomment "extension=php_sockets.dll" in my php.ini file.

Posted by Roger on April 07, 2010 at 01:12 PM CEST #

Thanks to All!! the answer to several of my questions lay in this page :)

Posted by Leon on April 07, 2010 at 05:35 PM CEST #

any ideas why socket_create is not found even though i've confirmed sockets extension is working from php_info ?

Posted by kyriakos on April 11, 2010 at 11:15 AM CEST #

Followed the installation XDebug Wiki and everything worked. XDebug shows up in phpinfo.
Final step is to fire up above test script in your browser. But this test script doesn't work for me it keeps on loading. I spend several hours on it thinking I did something wrong with the installation and setting it up.

Then I decided to just run NetBeans and just try to debug a simple PHP script and what do you think... it just works! So all the time I was thinking my installation was bad because the test script didn't work!!

Can someone explain why I can debug in NetBeans (using XDebug) but the testscript doesn't?

Posted by Jan on April 22, 2010 at 03:14 PM CEST #

for the fatal error on socket_create even after you enabled the extension :
When using wamp, you have 2 versions of php.ini :
The 1st, editable by right clicking on wamp icon is not used by the PHP command line (cli)
the 2nd php.ini which is CLI dedicated is located in

You'll need to manually edit this 2nd file and enable extension php_socket manually...

Posted by pit on May 26, 2010 at 11:27 AM CEST #

On Windows 7 I am getting MSVCR71.dll, OCI.dll, aspell-15.dll and libc.dll is missing from computer. Why is it missing? Where do I get these DLLs from?

Thank you in advance.

Posted by Rak on May 28, 2010 at 02:35 PM CEST #

I used both ways to test (webbrowser and CLI) and edited both php.ini (C:\\wamp\\bin\\apache\\apache2.2.8\\bin\\php.ini and c:\\wamp\\bin\\php\\php5.2.6\\php.ini). I used same settings in both ini's. None worked. When I run it just waits and nothing happens. If I debug using NetBeans it does work! So I guess your testscript doesn't work?!
XDebug does show up in my phpinfo so the XDebug installation worked.

I am using Windows XP SP3 and WAMP 2.0 (Apache 2.2.8 and PHP 5.2.6).

Posted by Jan on June 04, 2010 at 05:12 AM CEST #

I use xdebug with IIS7, PHP 5.3, FastCGI. The dll is set up correctly and I can debug php files both in notepad++ using DBG plugin and NetBeans 6.9.

The problem is that I can debug small php files, but when I open my project from existing files NetBeans stay in 'waiting for connection' forever.

I suspect this is not an xdebug problem, but somehow related to NetBeans

Any help?

Posted by Nasos on July 02, 2010 at 05:20 AM CEST #

A user discovered this tip:
- Only use those socket-based php test files like sparingly. When they hang, they can tie up the port and complicate the question. Reboot and restart Apache often. Also, don't forget to try them through a browser as well as the command line. If this gives you a fancy error screen with backtraces and some orange colouring, that's a good sign - that's xdebug at work!
For more information, see alanms' post of 13 August 2010 at

Posted by Jeffrey Rubinoff on August 16, 2010 at 09:37 AM CEST #

Make sure you have selected the correct index.php in your real Web Root" in your application.
Specify this setting by right-clicking on your current Project > Properties > Sources.
This will do the job ... at least for me

Posted by Schmunk on September 21, 2010 at 08:28 AM CEST #

I am using netbeans 6.9.1 and configuared xdebugger for php I am getting following message or status after debugger started

waiting for connection(netbeans-xdebug)

can any body help me...

Posted by James on January 10, 2011 at 03:24 AM CET #

OK, and how do I modify this procedure so that it does NOT go though the server, even a local one, but uses cli-executed scripts at BOTH ends of the connection? I want to debug some PHP code that is designed to work as a command line utility so I do not have a need for all the hassle involved in setting up a web server environment just so I can test whether my xdebug installation works.

Posted by Szczepan on January 17, 2011 at 09:34 PM CET #

Thanks to Radek for dbgtest.php. This allowed me to determine that my 64-bit Windows version of xdebug wasn't loading (although I have a 64-bit machine, xampp is a 32-bit executable). I downloaded the 32-bit version of xdebug and dbgtest.php then confirmed that xdebug is working correctly. Unfortunately, after trying all of the advice in this thread NetBeans IDE 6.9.1 STILL doesn't connect. I'm running Windows 7 with XAMPP 1.7.4.
NetBeans looks like it will be great when it works, but at the moment is just a source of frustration.

Posted by Keith on March 01, 2011 at 05:40 AM CET #

I am using NetBeans 6.9.1 with PHP 5.3.5 on Windows and although this blog gives good information, it still doesn't work for me.
When I run the test script dbgtest.php in the command line it doesn't output anything.
How can I debug the dbgtest.php? An echo right after socket_create does not create an out anymore. Does it mean, that the socket_create method already failed?
In phpinfo() it looks that XDEBUG is installed properly with the right attributes (xdebug.remote_enable is on, ...).
Any idea?

Posted by Ralph on March 18, 2011 at 02:04 AM CET #

hi everything works fine for me but the css for the xdebug result is missing. dont know wats wrong. could anyone tell me what went wrong???

Posted by manik on May 12, 2011 at 12:03 AM CEST #

Setting up xdebug with netbeans took me around couple of minutes. I see that a lot of people are having problems getting it working properly so I made this tutorial:

Posted by Arturito.Net on May 25, 2011 at 01:23 AM CEST #

To Arturito.Net: Thanks for the link.

Posted by Petr Pisl on May 25, 2011 at 04:29 AM CEST #

How do I unsubscribe from this thread?!

Posted by Bill on May 26, 2011 at 05:33 AM CEST #

When I try this code I get this error

Warning: socket_bind() [function.socket-bind]: unable to bind address [0]: Only one usage of each socket address (protocol/network address/port) is normally permitted. in C:\xampp\htdocs\info\xdebug.php on line 5

I am using Xampp 1.7.4 and xdebug 2.1.2 and php 5.3.5.

Is there a way to fix that?

Posted by guest on September 01, 2011 at 10:30 AM CEST #

The chrome plugin mentiones by Arturito works nicely (thanks!)... if Netbeans helps a bit, which it doesn't always do. It seems it doesn't always close the socket at port 9000 after ending a debug session, and I believe that's the main reason it sometimes waits forever for a connection. Then the unix "socket" command reports that the port is in use or just doesn't do anything. Using "netstat | grep 9000" or "lsof -n | grep 9000" shows a "java" (i.e. netbeans) connection. The solution I've found (so far) is just to close netbeans, so that port 9000 is no longer used; after restarting it, debugging works fine (so far).

Posted by guest on September 08, 2011 at 09:50 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed

This blogs is written by NetBeans developers who contribute to the PHP support mainly.


« June 2016