Once again... xdebug ports.

Seems like every 3 years this comes up again. So I'm attempting to run my phpunit tests via debug (laravel stack) and I get this:

Port 9,000 specified in settings is busy. Port 50,165 is free and can be used by Xdebug. Please update php.ini with xdebug.client_port=50165

with that recommended port changing on every attempt.

can someone shed any light on this? It's like whack a mole with this.

My php.ini is like this:

xdebug.remote_enable=1
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9000
xdebug.idekey="PHPSTORM"zend_extension = "C:\xampp\php\ext\php_xdebug-3.1.2-8.1-vs16-x86_64.dll"

and my intellij settings are like this:

and regardless of what I set either of these to, the error persists. Seems to have happened (again) after the 2022.3 update.


0

Hi there,

Exit PhpStorm, open terminal (with Admin rights) and run something like netstat -abn and see what process is listening on that TCP 9000 port.

If none -- launch PhpStorm and repeat the same again.

What process that will be? Could that be Docker or some another app?

 

P.S.

1. xdebug.remote_enable=1 is for Xdebug v2, It does nothing in v3. In fact -- it can print a notice in Xdebug log/console when it sees it.

2. Xdebug v3 uses 9003 port by default (as 9000 is used by php-fpm by default as well -- mainly affects Linux and mac though). It makes sense to start using 9003 as well.

0

#2, this is why this doesn't make any sense. I didn't explicitly declare a port for this at all, yet it appears that intellij is defaulting to 9000

0

To clarify, prior to having this problem my php.ini did not specify the client port, I added this after the fact in an attempt to debug it.

 

0

So ... have you managed to get it working again?

0

I just freed up the ports listeners on 9000 - 9003 and all is working again.
Not sure why I got such a flood of TCP connections. This seems to be the problem.

0

Great.

1. Do you remember what kind of services/apps were listening on those TCP 9000-9003 ports?

2. As I understand your solution (excluding freeing the aforementioned ports) also included changing the Xdebug port in the IDE settings from 9000 to 9003 and relaying on default xdebug.client_port value (or manually confirming/specifying 9003 there)?

(I'm answering Xdebug related questions occasionally here and there and it would be good to know what was causing the issue in the first place as it helps in making suggestions there + how it was resolved in the end).

 

 

#2, this is why this doesn't make any sense. I didn't explicitly declare a port for this at all, yet it appears that intellij is defaulting to 9000

Cannot speak about IntelliJ (or how PHP plugin behaves there), but PhpStorm uses "9003, 9000" (both ports) by default for newly created projects for about 2 years now (since Xdebug v3 was released). It will listen on both ports when using "green phone handle" icon but will use only first listed one when using Debug for CLI scripts (so the order matters here).

0

Not sure if this is relevant, but I frequently have this problem as well. I've tried changing the ports around (to the 50K-range) as recommended, but after a while it stops working again and I need to change back to 9000, 9003. I lose a lot of time on this.

I just encountered the problem and this time the solution was very simple: Restart PhpStorm. I'm not sure why it helped but I did open a new project ("Open in this window") and maybe somehow the PhpStorm was holding the port hostage from the old session after switching projects? (Wild guess.)

0

请先登录再写评论。