I’ve been trying to get debugging working in VS Code for hours and have read every tutorial and question and answer, but no luck.
I have a server using Turnkey Linux LAMP with PHP 7.4 and Xdebug 3.
On another Windows computer I have VS Code running and am trying to debug.
I have tried various settings, but currently VS Code launch.json
looks like this?
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"hostname": "192.168.20.110",
"pathMappings": {
"/var/websites/test": "${workspaceFolder}/",
}
}
On the server, php.ini
looks like this, although I have tried various:
[xdebug]
xdebug.mode=develop,debug
xdebug.discover_client_host=1
xdebug.client_port = 9003
xdebug.start_with_request=yes
Whenever I press the run button in VS Code I get
listen EADDRNOTAVAIL: address not available 192.168.20.110:9003
I have tried creating a firewall exception on the server for port 9003.
I have installed Xdebug extension in Chrome.
What am I missing?
2
Answers
It seems like the issue might be related to the address specified in your
launch.json
file. The error "EADDRNOTAVAIL: address not available" suggests that the specified IP address is not reachable or not assigned to your server.Here are some suggestions to troubleshoot and resolve the issue:
Check Server IP Address:
192.168.20.110
is the correct IP address of your Turnkey Linux LAMP server. You can check the IP address using theifconfig
orip a
command on the server.Use "localhost" or "127.0.0.1" as the Hostname:
"hostname"
in yourlaunch.json
file. This can sometimes resolve connection issues.Check Firewall Settings:
9003
is open and accessible. You may need to create an exception for this port.Verify Xdebug Settings:
Verify PHP Process:
phpinfo()
function to check if Xdebug is loaded.Check for Multiple Xdebug Configurations:
.ini
files can cause conflicts.Restart Services:
Review VS Code Output:
Try Different Ports:
launch.json
file. Make sure that the port you choose is not blocked by the firewall.Check for Typos:
launch.json
file.Reinstall Xdebug Extension in Chrome:
After making any changes, restart your server and try again. If the problem persists, review each step to ensure accuracy and consistency in your configurations.
First definitely remove the
hostname
setting fromlaunch.json
. This is the IP the IDE tries to bind to and as this is a remote IP of the server it cannot. Also do not uselocalhost
as then the server will not be able to communicate with the workstation.Path mappings could be wrong as you did not provide information how the workstation is accessing the files on the server (SMB, SSH, SFTP).
I suggest adding
xdebug_info();
in one of the php files that you open with a browser and see what output it generates.