Can't start listening for connections from 'xdebug': Port 18000 is busy

Hi,

I have a site running on vagrant (dev.mysite.com:8080) . Here's the xdebug settings in php.ini:

zend_extension="/usr/lib/php5/20090626/xdebug.so"
xdebug.default_enable = 1
xdebug.idekey = "vagrant"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_port = 18000
xdebug.remote_handler=dbgp
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.remote_host=10.16.24.204 ; IDE-Environments IP, from vagrant box.


Here are my settings in PHPstorm8:
http://picpaste.com/pics/AiV9SRTy.1421606432.png

http://picpaste.com/pics/Orqp44WY.1421606620.png

As soon as I click on 'start listening for PHP debug connection'  I get an error saying port 18000 is busy.

Port 18000 is free until I either start PHPStorm or start debugging session in chrome.

This is the first time I am using PHPStorm and my assumsion is that my php.ini settings and PHPStorm settings are incorrect.  Please assist.

0
15 comments

Hi there,

Use netstat and check who is using that port. If anything -- change to another one.

0

@Andriy Bazanov as I tried to explain in my original post the port is free until I start phpStorm.  I used sudo lsof -n -i4TCP:18000 to verify.  To clarify: phpstorm starts listening on port 18000 as soon as it starts.   Meaning it starts listening even before I click "start listening for php debug connection" button. Same thing was happing when I was using port 9000.   Is there something wrong in my settings?

0

There is nothing wrong with your settings (as per your screenshots).

I do not see how PhpStorm can start listeing on xdebug port (be it 9000 or 18000) automatically on start:

  • never did it to me on my Windows 7 machines (2 PCs) .. and so far I have not hear anything like that here on forum on Issue Tracker.
  • it has no code to automatically "listen for incoming debug connections" (which some people do request actually).


Right now I may only suggest:

  • disable all 3rd party (non bundled by default) plugins and see if it will make any difference
  • check your idea.log for any possible additional hints (what else may be using that port)
  • double check your IDE settings for that port (maybe do global search for "18000" in all config files) -- https://intellij-support.jetbrains.com/entries/23358108-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs . Possibly you have changed some another value elsewhere (my only thought in thig regard right now would be built-in simple web server)
  • backup and delete all IDE configs and start from scratc (as last resort, of course) -- see URL above
0

Deleting all the config files and then putting in all setttings did the trick.  PhpStorm no longer starts listeing on any port soon as it starts.  Remote debuggin is now working :)

0

Just a note for others that have this issue - I was following the steps outlined here for profiling plugin cpu usage, and I started to experience this issue.  Went away after I removed the line `-agentlib:yjpagent=delay=10000,probe_disable=*` from phpstorm.vmoptions.  One more option to try if folks are still stuck.

1

Yes, the IDE is buggy - it makes the problem and a support tells you have a problem, not they. 

I used PhpStorm, now using Intellij, the problem still the same - IDE occupies 9003 port and cannot use it :D

But the support for years tell the same - it is impossible, there is something on your side!

I am very angry about. 

What cache should I delete? Windows 10.




0

Deleting of files in that dirs didn't help

0

@rokkybaliboa

Yes, the IDE is buggy - it makes the problem and a support tells you have a problem, not they. 

Unlikely. In all cases that I remember where standard Xdebug port was involved it was a user error (a person is used that port in the wrong place) or a system (another app already uses that port -- because user did not know about it (the case with 9000 port, used by default by php-fpm) or misconfiguring their docker etc.)

 

Now, as per your 2nd screenshot (the one with netstat info), it's your IntelliJ IDEA that listens on that 9003 port (and Docker on 9000 -- why?). These ports is not something that the IDE or Docker will use for own needs, so extremely likely it will be a misconfiguration by the user.

For 9003 -- go to the IDE settings and type "port" in the search box -- now go trough all places (should be only a few of them where the input field is) and post a screenshot of all places where it is used.

0

That is Laradock default settings - listen to 9000 port inside and show it on 9003 port outside.

Previous time I changed the port to 9006 and it helped. This time I checked before is 9006 port is free, changed outer docker port to 9006, but it doesn't help, now it is busy :D
Finally I removed the IDE, removed install and app local and roaming dirs. The only thing I forgot is IDE's docker container. And installed again... IDE still remembers me e.g., my test run configuration!

I can give a remote access with TeamViewer if needed

0

That is Laradock default settings - listen to 9000 port inside and show it on 9003 port outside.

Sorry, this does not make sense to me (what for / what it does). Maybe you are explaining it wrong or misunderstood what it does...

Xdebug port is to be used by the IDE and nothing else (except Xdebug itself, ofc).

Finally I removed the IDE, removed install and app local and roaming dirs.

Good. So you have deleted the IDE-wide settings.

And installed again... IDE still remembers me e.g., my test run configuration!

Run/Debug Configurations are Project-level settings and stored in PROJECT_ROOT/.idea folder.

I can give a remote access with TeamViewer if needed 

It's possible .. but now now (Monday morning). Maybe later in the day if you still will be unable to solve it.

0

Oh, yes, now I removed .idea dirs in projects and even registry data.

And set up PhpStorm. The problem persists

0

So it's a docker (Laradoc) issue then?

Just in case:

  1. Xdebug port is to be used by the IDE ONLY. The IDE must be the one that listens on Xdebug port.
  2. It's Xdebug that connects to the IDE and NOT other way around.
  3. You do not need to expose/forward Xdebug port in your docker container.

 

Shut down your docker / make sure no containers are running at all and try activating "phone handle" icon then. Does it work?

0

I noticed there is probably one place on screens is repeated, so checked ports again. Got these 3 processes on 9003 port:

[wslhost.exe]
[com.docker.backend.exe]
[com.docker.backend.exe]

Then I closed Docker Desktop as you wished. There were not any 9003 occupied ports.

Then I activated "phone handle", it works, there are 2 processes phpstorm64.exe on 9003 ports

> So it's a docker (Laradoc) issue then?

I don't know. I hoped there was an IDE's cache with 9006 port because I did have working debug in PhpStorm before, a year ago, after replacing 9003 occurrences with 9006. But yesterday it didn't help

 

0

You are right!

I removed these lines from Laradock docker-compose.yml:

      ports:
        - "${PHP_FPM_XDEBUG_PORT}:9003"

and xdebug in PhpStorm now works, there is no "Port 9003 is busy" message, I see variables' values.

 

Intellij IDE is not buggy, I am buggy, thanks a lot for your help!

0

I hoped there was an IDE's cache with 9006 port because I did have working debug in PhpStorm before, a year ago, after replacing 9003 occurrences with 9006. But yesterday it didn't help

Should work -- the IDE does not "cache" anything here.

A few points to remember:

  1. If the IDE is listening on some Xdebug port already and you have changed that port in the IDE settings, then you need to stop the "phone handle" (and/or close all active PHP debug sessions) in order for the IDE to start using new port. The IDE will not restart existing running bindings just like that.
  2. Make sure that you have also changed the port on the PHP/web server end (i.e. restart php-fpm/Apache). If you are unsure -- call "xdebug_info();" in your test.php script to see what the live values Xdebug is using right now.
0

Please sign in to leave a comment.