skip to Main Content

I need to set up Xdebug on my local machine which will connect to the remote development server.
My launch.json in VScode looks like this-

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "hostname": "a.b.c.d", //Remote server IP
            "port": 9000
        }
    ]
}

I have added this code in /etc/php/7.2/cli/conf.d/20-xdebug.ini file

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_mode = req
xdebug.idekey="vsc"

I have added the xdebug extension in my browser.
I get this error when I try to click Start Debugging

Error: listen EADDRNOTAVAIL: address not available  a.b.c.d:9000 
code: 'EADDRNOTAVAIL',   
errno: -4090,   
syscall: 'listen',   
address: 'a.b.c.d',   
port: 9000

Is there anything I am missing?

2

Answers


  1. It means something else is already listening on port 9000. For example. PHP-FPM. You need to set the port to something else, such as 9003, as that is what Xdebug 3 uses. You then need to use 9003 both for xdebug.remote_port and in "port" : 9003 in the VS Code launch.json file.

    Login or Signup to reply.
  2. Firstly, it’s probably the other way around. Your local machine has the IDE (vscode + php-debug vscode extension) and the remote development server has the web server with PHP and Xdebug PHP extension. The remote server then connects back to the IDE when a web request starts.

    The hostname in launch.json tells the IDE "on what local network interface" to listen for incoming connections. This should not be needed in most cases and should be removed – the IDE can just listen on all local network interfaces.

    The xdebug.remote_host on the remote development server should contain the IP of your IDE not localhost – unless you are doing some port forwarding magic.

    Obviously the remote server must be ablet to TCP connect to your IDE for this to work.

    You are probably also missing path mapping as the PHP source files on your local machine will be in different location than on the remote server.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search