I'm struggling with this error message. Sometimes I cannot run xdebug on Visual Studio Code after upgrading or restarting the editor. Here's a screenshot of the error:
After several minutes to find out what happens on my machine, i figure it out how to solve my problem.
Because the xdebug is running based on port 9000 and i see on the Debug Console (VSCode) has message listen EADDRINUSE :::9000, i think there is an another process running on port 9000 so i check what process running on it by this command
sudo netstat -nlp | grep :9000
The command above will show you what process running on port 9000, then i get this result
tcp6 0 0 :::9000 :::* LISTEN 14856/hhvm
HHVM was take over port of xdebug by default, so i need to take it service down or change the port number.
Tips:
You can also use lsof to view process on specific port
I had same issue while I was start using VSCode. Well i took 3 hours to figure out what is exactly issue, I just stared with some step by step debugging like what port being used and what are the other settings.
Finally I was lucky and got the solutions :) So I shared with everyone. You can check what is my findings and what you should need to setup to get Xdebug work with VSCode.
#VSCode & PHP Debug
Setup Xdebug in VS Code to debug your PHP Code on fly. follow the step by step instruction to setup xdebug properly.
Open phpinfo & find xdebug, If found then you have installed xdebug successfully!
If Wamp Restart But localhost not opening then try to change PORT. May PORT using by any other
application already.
Open PHP Project Folder and try to Debug code..If you are getting following error
VS Code Debug adapter process has terminated unexpectedly
or
VS Code Console Error -> listen EADDRINUSE::900)
Thats mean the PORT 9000 is currently using by another programe, You may have running PHPStorm Xdebug or any other application who using the PORT 9000. Try to Close the PHPStorm or Other programe and try to debug again.
Still getting error then try to find which program using PORT 9000 and kill them .. Still getting error try to change PORT in php.ini and launch.json and restart wamp and VSCode.
Now you can see XDEBUG working in VSCode.
> #### Example Code to test
<?php
/*
|--------------------------------------------------------------------------
| PHP XDebug Code Example - VS Code
|--------------------------------------------------------------------------
|
| Information:
|
| VS Code :
| Version : 1.19.2
| Commit : 490ef761b76b3f3b3832eff7a588aac891e5fe80
| Date : 2018-01-10T15:55:03.538Z
| Shell : 1.7.9
| Renderer : 58.0.3029.110
| Node : 7.9.0
| Architecture : x64
|
| Windows : 10
|
| WAMP Server : 3.1.0
| PHP : 7.1.9
| APACHE : 2.4.27
| MySQL : 5.7.19
|
| PHP INI PATH : D:\wamp64\bin\apache\apache2.4.27\bin\php.ini
| [Xdebug]
| zend_extension = "d:\wamp64\bin\php\php7.1.9\zend_ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"
| xdebug.remote_enable = 1
| xdebug.remote_autostart = 1
| xdebug.remote_port = "9000"
| xdebug.profiler_enable = 1
| xdebug.remote_host = "localhost"
| xdebug.profiler_output_dir = "d:\wamp64\tmp"
|
*/
// first loop
for ($i=0; $i < 10; $i++) {
echo $i;
}
echo PHP_EOL;
// second loop
for ($i = 0; $i < 20; $i++)
{
echo $i;
}
/* End of file php-test.php */
/* Location: /wamp64/www/test/php-test.php */
After several minutes to find out what happens on my machine, i figure it out how to solve my problem.
Because the xdebug is running based on port
9000
and i see on theDebug Console
(VSCode) has messagelisten EADDRINUSE :::9000
, i think there is an another process running on port9000
so i check what process running on it by this commandThe command above will show you what process running on port
9000
, then i get this resultHHVM was take over port of xdebug by default, so i need to take it service down or change the port number.
Tips:
You can also use
lsof
to view process on specific portI had same issue while I was start using VSCode. Well i took 3 hours to figure out what is exactly issue, I just stared with some step by step debugging like what port being used and what are the other settings.
Finally I was lucky and got the solutions :) So I shared with everyone. You can check what is my findings and what you should need to setup to get Xdebug work with VSCode.
#VSCode & PHP Debug
Setup Xdebug in VS Code to debug your PHP Code on fly. follow the step by step instruction to setup xdebug properly.
Gif action:
How to setup PHP Debugging (xdebug) with VSCode?
1. First of all Install VSCode
2. Install PHP Debug Adapter for Visual Studio Code
3. Install XDebug in WAMP
Example
OR
4. Restart WAMP Server
How can you find out which process is listening on a port on Windows?
Setup XDebug in VSCode
5. Update VSCode Setting for PHP to add PHP Executable Path
6. Save and restart VSCode
Open PHP Project Folder and try to Debug code..If you are getting following error
or
Thats mean the PORT 9000 is currently using by another programe, You may have running PHPStorm Xdebug or any other application who using the PORT 9000. Try to Close the PHPStorm or Other programe and try to debug again.
Still getting error then try to find which program using PORT 9000 and kill them .. Still getting error try to change PORT in php.ini and launch.json and restart wamp and VSCode.
Now you can see XDEBUG working in VSCode.
> #### Example Code to test
Thanks :)