Home » Php » php – Xdebug for remote server not connecting

php – Xdebug for remote server not connecting

Posted by: admin April 23, 2020 Leave a comment


I want a team using different computers to be able to debug PHP on a remote server, but I am having a hard time getting Xdebug to work in NetBeans 7.0.1. I’ve tried many online tips, but to no avail.

For the record, I have successfully installed Xdebug locally on a Windows 7 machine running WampServer. So I can debug PHP with breakpoints in NetBeans, provided I set the Project Properties->Run Configuration->Run As property to Local Web Site. However, as stated above my goal is to debug in NetBeans on a Remote Web Site.

My server is a Ubuntu 11.04 machine. I have used the output from http://www.xdebug.org/find-binary.php to put the proper binary on the machine. I have modified all php.ini files I could find (in both the php5/apache2 and php5/cli directories) to include these lines:


If I check the phpinfo.php web page, it says:

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

So Xdebug does seem to be installed properly. Still, when I try debugging in NetBeans, I get the endless status bar message Waiting For Connection (netbeans-xdebug). When I hit the stop button I get No connection from xdebug was detected within X seconds. The reason could be that xdebug is not installed or not properly configured.

Maybe I’m confusing local settings with server settings here? A post said xdebug.remote_host should be set to the IP of the machine running NetBeans, but I want a team to be able to debug using machines with different IP addresses. A problem could be port 9000, but I have checked that it is not blocked.

Any help that could clarify this would be appreciated!

How to&Answers:

The server running PHP (and XDebug) needs to be able to connect to your workstation/desktop.


So you’ll need the server set up accordingly by either telling it to connect to a specific IP-address (xdebug.remote_host) or to automatically “connect back” (xdebug.remote_connect_back). The latter has some security implications, though. These are outlined in the manual.


For me, xdebug.remote_connect_back = On does not work.
What I did was to set ssh port forwarding on my client machine.

xdebug config on the remote machine:

xdebug.remote_handler = dbgp
xdebug.remote_mode = req

forward ports on the client machine:

ssh -g -N -lusername -R9000: [remote.host.ip]

The shell access on the remote machine must be allowed.


The key directive is this:

xdebug.remote_connect_back = On

This allows the web server to connect to whatever computer is asking for a debugging session. This way you don’t have to hard-code an IP address and are able to share Xdebug. This directive was not present in earlier versions and is often omitted from tutorials and documentation.

You also need to verify that every client computer accepts incoming connections to port 9000 (xdebug.remote_port). This includes configuring the firewall and making sure the debugger client is up and running


In my case, those commands helped me:

xdebug.remote_enable = On

Notice: the debugger will work even if GET/POST/COOKIE variable is not present because of ‘xdebug.remote_autostart=1’


I had the same issue a couple of times while trying to configure docker and after scratching my head multiple times I realized this was the way to fix it. So I decided to put this here as an answer for my future self.

Most of the time the Dockerfile was adding this this statement to php.ini:

xdebug.remote_connect_back     = on

This would cause everything to seem okay but somehow no debug connections were actually caught by PHP storm. Replacing the line above with the following instantly fixes stuff for me.

xdebug.remote_connect_back     = 0
xdebug.remote_host             = host.docker.internal

Of course, after that you still need to run:
$ docker-compose down
$ docker-compose build and
$ docker-compose up -d


Thanks for xdebug.remote_connect_back = On on server side php.ini
Also I had to use this plugin for Chrome to be able to start debugging session in PhpStorm


You will need set:

xdebug.remote_host= is the client’s ip, where you working with the IDE


What page extension are you firing up to start debugging? I remember I went nuts and spent sleepless nights where all settings with XDebug are going great. The problem was I was not starting up with .PHP rather starting up with .HTML.

If you are then try starting up your debugging with .PHP file.