Skip to content

XDebug fails to connect because vscode-php-debug is listening on IPv6 #288

Description

@mscharley

PHP version: 7.1.20
XDebug version: 2.6.0
Adapter version: 1.12.3

Your launch.json:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "pathMappings": {
        "/portal": "${workspaceFolder}",
      },
      "port": 9000,
      "log": true
    },
    {
      "name": "Launch currently open script",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9000
    }
  ]
}

XDebug php.ini config:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_host=host.docker.internal

XDebug logfile (from setting xdebug.remote_log in php.ini):

Log opened at 2018-08-01 02:13:59
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 172.19.0.1:9000.
W: Creating socket for '172.19.0.1:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-08-01 02:13:59

Adapter logfile (from setting "log": true in launch.json):

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true }

Code snippet to reproduce:

<?php
phpinfo();

Also relevant:

$ lsof -nP -i4TCP:9000
COMMAND     PID            USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Code\x20H 46903 matthewscharley   28u  IPv6 0x32d841ebd93c8e67      0t0  TCP *:9000 (LISTEN)

It would be great to be able to specify a bind address, which would then let me solve this easily. Alternatively, binding to both IPv4 and IPv6 would be an even better solution.

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