Daniel Fuhrer
Daniel Fuhrer

Reputation: 13

Xdebug not listening on port (Windows)

I installed Xdebug on my Windows 2019 Server as described on the documentation. But the server is not listening on the given port. My php.ini settings:

[xDebug]
zend_extension="C:\Program Files\PHP\ext\php_xdebug-3.0.4-8.0-vs16-nts-x86_64.dll"
xdebug.start_with_request = yes
xdebug.client_host = x.x.x.x
xdebug.client_port = 9003
xdebug.mode = trace, debug
xdebug.collect_assignments = true
xdebug.collect_return = true
xdebug.log = "C:\inetpub\logs\xDebug.log"
xdebug.log_level = 7
xdebug.output_dir = "C:\inetpub\logs\xDebug"
xdebug.trace_output_name = trace.%H

But if I check with netstat -aon, the server is not listening on the port 9003. No matter what port number I add. The installation is a fresh Windows Server 2019 with IIS and PHP configured.

C:\Users\Administrator>php -v
PHP 8.0.9 (cli) (built: Jul 29 2021 14:12:27) ( NTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

In the log file, I get only:

[2236] Log opened at 2021-08-05 08:38:25.637570
[2236] [Step Debug] INFO: Connecting to configured address/port: x.x.x.x:9003.
[2236] [Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: 10.233.233.2:9003 (through xdebug.client_host/xdebug.client_port) :-(
[2236] Log closed at 2021-08-05 08:38:25.864249

The trace is working fine.

It also doesn't work on my Windows 10 21H1 machine. The same issue.

Upvotes: 1

Views: 3740

Answers (2)

Ilia Yatsenko
Ilia Yatsenko

Reputation: 832

By configuring client_host and client_port you tell xDebug where to connect. And then you should listen for incoming connections, for example, in your IDE. If you want to debug code on a remote server, and use PhpStorm locally, you may need to setup ssh tunnel to allow remote xdebug connect to your local machine. See https://www.jetbrains.com/help/phpstorm/remote-debugging-via-ssh-tunnel.html#debug-php-cli-scripts-with-remote-php-interpreters-or-via-ssh-tunnel

Upvotes: 1

Derick
Derick

Reputation: 36784

But if I check with netstat -aon, the server is not listening on the port 9003

That is correct, because it is the IDE that needs to listen for incoming connections from Xdebug. It is the latter that connects to the IDE.

This is also in the documentation: https://xdebug.org/docs/step_debug#configure:

…you need to tell Xdebug where to make the debugging connection to, as it is Xdebug that initiates the communication to the IDE, and not the other way around.

Upvotes: 2

Related Questions