VSCode and PHP with XDebug and PHP Debug extension and IISExpress

1

I am trying to use the PHP Debug extension in VS Code. I have followed the instructions and pasted the phpinfo contents into the wizard and downloaded the appropriate dll. I get the following error

launch.json

"version": "0.2.0",
"configurations": [
    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000,
        "log": true
        },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000
    }
]

php.ini

[XDEBUG]
zend_extension = C:\PHP\ext\php_xdebug-2.9.6-7.4-vc15-nts.dll
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_mode = req

If I choose the listen option having previousy started IISExpress I get this error

Error: listen EACCES: permission denied 0.0.0.0:9000 at Server.setupListenHandle [as _listen2] (net.js:1211:19) at listenInCluster (net.js:1276:12) at Server.listen (net.js:1364:7) at c:\Users\me.vscode\extensions\felixfbecker.php-debug-1.13.0\out\phpDebug.js:236:24 at new Promise () at createServer (c:\Users\me.vscode\extensions\felixfbecker.php-debug-1.13.0\out\phpDebug.js:184:40) at PhpDebugSession. (c:\Users\me.vscode\extensions\felixfbecker.php-debug-1.13.0\out\phpDebug.js:240:27) at Generator.next () at c:\Users\me.vscode\extensions\felixfbecker.php-debug-1.13.0\out\phpDebug.js:7:71 at new Promise () { code: 'EACCES', errno: 'EACCES', syscall: 'listen', address: '0.0.0.0', port: 9000 }

If I choose the other option and start VS Code first, I get an IISExpress error

Failed to register URL "http://localhost:9000/" for site "XXXXXXX-0f34f450-230f-4d11-8878-1a90a024dcf6" application "/". Error description: The process cannot access the file because it is being used by another process. (0x80070020)

I know port 9000 is not used because if I run this command when nothing is running it shows nothing running

Get-Process -Id (Get-NetTCPConnection -LocalPort 9000).OwningProcess

Clearly both sides can start port 9000 but they are not happy sharing the same port. What am I missing?

php
visual-studio-code
xdebug
iis-express
asked on Stack Overflow Aug 1, 2020 by Rob Sedgwick

1 Answer

1

My mistake was the site was also running on the port 9000. It needs to be a completely different port to XDebug which listens on its own port.

iisexpress.json

{
  "port": 1785,
  "path": "C:\\YourSite",
  "clr": "v4.0",
  "protocol": "http"
}
answered on Stack Overflow Aug 2, 2020 by Rob Sedgwick

User contributions licensed under CC BY-SA 3.0