Skip to content

Debugging Error Xdebug: [Step Debug] Could not connect to debugging client #11

Description

@stefnats

Hello,

i'm using this container with the following config (devcontainer.json):

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.0/containers/php
{
	"name": "PHP",
	"build": {
		"dockerfile": "Dockerfile",
		"args": { 
			// Update VARIANT to pick a PHP version: 8, 8.0, 7, 7.4, 7.3
			"VARIANT": "8",
			"NODE_VERSION": "lts/*"
		}
	},
	
	// Set *default* container specific settings.json values on container create.
	"settings": { 
		"php.validate.executablePath": "/usr/local/bin/php"
	},

	// Add the IDs of extensions you want installed when the container is created.
	"extensions": [
		"felixfbecker.php-debug",
		"bmewburn.vscode-intelephense-client",
		"mrmlnc.vscode-apache",
		"calebporzio.better-phpunit"
	],

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [8080],

	// Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference.
	"portsAttributes": {
		"8000": {
			"label": "Hello Remote World",
			"onAutoForward": "notify"
		}
	},

	// Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'.
	// "otherPortsAttributes": {
	// 		"onAutoForward": "silent"
	// },

	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"

	// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
	"remoteUser": "vscode"
}

When i run any php process i receive this error

Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9000 (through xdebug.client_host/xdebug.client_port) :-(

Dockerfile is still as is: https://github.com/microsoft/vscode-remote-try-php/blob/67e233b925a64f90a46092879ed82b9e6d89f19e/.devcontainer/Dockerfile

Am i doing something wrong? Thanks in advance!

Activity

  1. ikhvjs commented on Sep 30, 2021

    @ikhvjs

    Same issue with the default preconfig image of PHP

    devcontainer.json

    // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
    // https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/php
    {
    	"name": "PHP",
    	"build": {
    		"dockerfile": "Dockerfile",
    	},
    	"settings": { 
    		"php.validate.executablePath": "/usr/local/bin/php"
    	},
    	"extensions": [
    		"felixfbecker.php-debug",
    		"bmewburn.vscode-intelephense-client",
    		"mrmlnc.vscode-apache"
    	],
    	"forwardPorts": [8080],
    	"remoteUser": "vscode"
    }

    Dockerfile

    ARG VARIANT="7.4"
    FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}
  2. mabasic commented on Sep 30, 2021

    @mabasic

    This is normal when not debugging the application. By default xdebug listens for a "debugging" connection. If you are not debugging, then it displays the warning that you are seeing. When you try running your application with F5 (debugging mode) then you will not see that message.

  3. ikhvjs commented on Sep 30, 2021

    @ikhvjs

    mabasic , I try to F5 to debug. I can see the server is running in remote container localhost:9003 and I try to browse the page in local localhost:9003, but there is no response.

    I also try in terminal with telnet localhost 9003 in local and there is no connection as well.

  4. mabasic commented on Sep 30, 2021

    @mabasic

    When you start debugging in vs code, you should open the browser to the port on which your application is running, not the port of the debugger.

    Set a breakpoint in vscode, make a request to your application so that the breakpoint is triggered and you will see that the application execution is paused and that you can see the current variables in vsvode.

  5. ikhvjs commented on Sep 30, 2021

    @ikhvjs

    mabasic , I try your suggestion. when you run F5 and enter the debugging mode, you can see your runing process is on the port 9003. I try to browse both port 8080 and 9003, but I cannot reach both of them.
    You can see the ports from the ports tab of VSCODE terminal panel below:
    image

  6. mabasic commented on Sep 30, 2021

    @mabasic

    See the readme for debugging instructions. I think that you need to start the server first.

  7. ikhvjs commented on Sep 30, 2021

    @ikhvjs

    mabasic , Thanks. I manage to solve the issue. It turns out that I use the default launch.json from VScode and it doesn' work. I try to copy the launch.json of the repo and it works fine.

  8. buyfhuhhhj-crypto commented on Oct 1, 2025

    @buyfhuhhhj-crypto

    Hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions