View Issue Details

IDProjectCategoryView StatusLast Update
0001877XdebugStep Debuggingpublic2021-03-27 13:19
ReporterTomaszKane Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionunable to reproduce 
PlatformLinuxOSKDE NeonOS Version5.19
Product Version3.0.0beta1 
Summary0001877: Xdebug from docker container can't connect to client
Description

Hi,
I try to use new Xdebug on my laptop T490 with KDE Neon and PhpSorm.
Project runs on few docker containers (below config for nginx and php)

What is missing or broke with my configuration?

Steps To Reproduce

install xdebug-3.0.0beta1via PECL and enable it (on php 7.4 fpm container)

write xdebug config:

xdebug.mode=debug
xdebug.discover_client_host=1
xdebug.cli_color=1
xdebug.html_errors=2
xdebug.var_display_max_depth = 8
xdebug.var_display_max_children = 128
xdebug.var_display_max_data = 1024
xdebug.idekey=PHPSTORM
xdebug.log=/var/log/xdebug.log

docker-compose:

version: "3"
services:
php-7.4:
build: ./docker-images/php-7.4
image: ap/php:7.4
container_name: sp-php-7.4
expose:

  • "${SSH_PORT}"
    ports:
  • "${SSH_PORT}:22"
    environment:
  • X_LEGACY_GD_LIB=${X_LEGACY_GD_LIB}
  • GITHUB_API_TOKEN=${GITHUB_API_TOKEN}
  • TEST_RUNTIME_PATH=/tmp/runtime
    volumes:
  • ~/.composer-docker/cache:/root/.composer/cache:delegated
  • ~/.gitconfig:/root/.gitconfig
  • ${WORKSPACE_DIR}:/var/www
  • ~/.ssh:/root/ssh:ro

    nginx-1.19:
    build: ./docker-images/nginx-1.19
    image: ap/nginx:1.19
    container_name: sp-nginx-1.19
    depends_on:

  • php-7.4
    environment:
  • PHP_CGI_PASS=${PHP_CGI_PASS}
    ports:
  • "${NGINX_PORT}:80"
  • "${NGINX_SSL_PORT}:443"
    volumes:
  • ./vhosts:/etc/nginx/conf.d-dist
  • ${WORKSPACE_DIR}:/var/www

Browser - Firefox with Cookie:

XDEBUG_SESSION=PHPSTORM

PhpStorm with config like on attached screenshos
(with mapped project root directory)

Listening is on:

$ lsof -i :9003 | grep LISTEN
java 5130 kane 23u IPv6 3040907 0t0 TCP *:9003 (LISTEN)

/etc/hosts like:
172.17.0.1 some.address.pl

Additional Information

php -v

PHP 7.4.8 (cli) (built: Jul 9 2020 23:21:18) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies
with Xdebug v3.0.0beta1, Copyright (c) 2002-2020, by Derick Rethans

xdebug log:

[6] Log opened at 2020-11-02 17:20:12.510627
[6] [Step Debug] INFO: Checking remote connect back address.
[6] [Step Debug] INFO: Checking header 'HTTP_X_FORWARDED_FOR'.
[6] [Step Debug] INFO: Checking header 'REMOTE_ADDR'.
[6] [Step Debug] INFO: Client host discovered through HTTP header, connecting to 172.22.0.1:9003.
[6] [Step Debug] WARN: Could not connect to client host discovered through HTTP headers, connecting to configured address/port: localhost:9003. :-|
[6] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29).
[6] [Step Debug] WARN: Creating socket for 'localhost:9003', connect: Cannot assign requested address.
[6] [Step Debug] ERR: Could not connect to debugging client. Tried: 172.22.0.1:9003 (from REMOTE_ADDR HTTP header), localhost:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
[6] Log closed at 2020-11-02 17:20:12.868660

Tagsfpm, Nginx, PHPStorm
Attached Files
Screenshot_20201102_184329.png (9,688 bytes)   
Screenshot_20201102_184329.png (9,688 bytes)   
Screenshot_20201102_184346.png (68,507 bytes)   
Screenshot_20201102_184346.png (68,507 bytes)   
Screenshot_20201102_184537.png (26,805 bytes)   
Screenshot_20201102_184537.png (26,805 bytes)   
Operating SystemDebian
PHP Version7.4.0-7.4.4

Activities

derick

2020-11-03 17:24

administrator   ~0005494

I don't think there is anything wrong with Xdebug here. It merely says the following:


[6] [Step Debug] ERR: Could not connect to debugging client. Tried:
172.22.0.1:9003 (from REMOTE_ADDR HTTP header),
localhost:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(

And that indicates that Xdebug can't, or didn't connect, to the right IP address.

On the machine where you ran "lsof -i :9003 | grep LISTEN", what is the output of "sudo ifconfig" ?

TomaszKane

2020-11-10 08:17

reporter   ~0005506

$ sudo ifconfig

br-09ed3aef8b95: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.19.0.1 netmask 255.255.0.0 broadcast 172.19.255.255
ether 02:42:93:ab:05:44 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-126beb512707: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.23.0.1 netmask 255.255.0.0 broadcast 172.23.255.255
ether 02:42:ef:f1:3a:fa txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-1b9f61aa11ae: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.22.0.1 netmask 255.255.0.0 broadcast 172.22.255.255
inet6 fe80::42:daff:fe19:636f prefixlen 64 scopeid 0x20<link>
ether 02:42:da:19:63:6f txqueuelen 0 (Ethernet)
RX packets 539 bytes 2531301 (2.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 589 bytes 166636 (166.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-1e59254eafcf: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.20.0.1 netmask 255.255.0.0 broadcast 172.20.255.255
ether 02:42:35:49:69:8e txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-43e421f671a5: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.24.0.1 netmask 255.255.0.0 broadcast 172.24.255.255
ether 02:42:9a:79:3b:3b txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-f1dea2c77d19: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:14:c7:86:14 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-feeef05eccd0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.21.0.1 netmask 255.255.0.0 broadcast 172.21.255.255
ether 02:42:72:a6:03:0f txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:b6:2e:af:fb txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 98:fa:9b:22:bc:f1 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xbd700000-bd720000

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 2325 bytes 203753 (203.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2325 bytes 203753 (203.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth585b027: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::c0a0:25ff:fefb:f552 prefixlen 64 scopeid 0x20<link>
ether c2:a0:25:fb:f5:52 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 3466 (3.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth702dc10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::7c03:b3ff:fe47:6d17 prefixlen 64 scopeid 0x20<link>
ether 7e:03:b3:47:6d:17 txqueuelen 0 (Ethernet)
RX packets 93 bytes 123638 (123.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 113 bytes 27352 (27.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth725fd74: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::503b:b3ff:fea6:be57 prefixlen 64 scopeid 0x20<link>
ether 52:3b:b3:a6:be:57 txqueuelen 0 (Ethernet)
RX packets 55 bytes 18946 (18.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 99 bytes 13796 (13.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vethbc74d65: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::50d2:e5ff:fe92:f9c1 prefixlen 64 scopeid 0x20<link>
ether 52:d2:e5:92:f9:c1 txqueuelen 0 (Ethernet)
RX packets 71 bytes 121438 (121.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 106 bytes 122278 (122.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vethdd1c2c2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::4451:daff:febe:b600 prefixlen 64 scopeid 0x20<link>
ether 46:51:da:be:b6:00 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 34 bytes 3726 (3.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.118 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::8d80:eda1:46e8:aa2e prefixlen 64 scopeid 0x20<link>
ether 38:00:25:8a:0b:83 txqueuelen 1000 (Ethernet)
RX packets 14585 bytes 15777311 (15.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6396 bytes 1101637 (1.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

TomaszKane

2020-11-10 08:18

reporter   ~0005507

cat /etc/hosts

172.17.0.1 some.address.pl

TomaszKane

2020-11-10 08:23

reporter   ~0005508

Thanks for the answer, derick. I know it's probably not a Xdebug bug, but I hope someone here will be able to tell me what I did wrong. Or how to run Xdebug step by step in an astepping configuration:

  • Debian / Ubuntu based OS
  • PHP in docker container
  • PHPStorm

You can find many guides on the web on how to run the debugger in a similar configuration, but none of them explain what to do in case of problems - i.e. how to debug the launch of XDebug ;-)

TomaszKane

2020-11-10 08:57

reporter   ~0005509

In example: how to debug Xdebug port?

  • run phpinfo() or php -i | grep xdebug and look at "xdebug.remote_port => 9003 => 9003"
  • in PhpStorm: Settings -> Languages & Frameworks -> PHP -> Debug: Xdebug -> Debug port: 9003
  • in PhpStorm: Start Listening
  • check listening: lsof -i :9003 | grep LISTEN

Now you are sure that everytihng touching the port is configured properly.

derick

2020-11-14 10:10

administrator   ~0005530

That's not quite true, for Xdebug 3 I've been working on some docs for this: https://3.xdebug.org/docs/errors#DBG-E-NOCON — You'd get that link when you use xdebug_info() to show you the issues.

You seem to have loads of "172.17.x" networks, I suppose they're all internal docker ones?

I think that instead of using "some.address.pl" you should use "172.17.0.1" in your PhpStorm config, as that seems to be the right address, but it wants to connect to 172.22.0.1 as per the error message. Why the domain some.address.pl does not resolve to that, I don't know. I'd generally recommend that if you use docker, you also don't rely on xdebug.discover_client_host=1, but hard code it in php.ini (or friends) with the right IP address (172.17.0.1, I believe).

heil

2020-12-18 08:42

reporter   ~0005594

In my case containers have no access to the host on any port.

sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 9003 -j ACCEPT helped to fix

heil

2020-12-18 08:42

reporter   ~0005595

In my case containers have no access to the host on any port.

sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 9003 -j ACCEPT

helped to fix

derick

2020-12-30 12:15

administrator   ~0005624

I can't reproduce this, and no more feedback was provided. Please reopen if you can provide more information.

TomaszKane

2021-03-27 13:19

reporter   ~0005817

Solution was easy and sad:
https://stackoverflow.com/a/66831751/1829368

Issue History

Date Modified Username Field Change
2020-11-02 17:56 TomaszKane New Issue
2020-11-02 17:56 TomaszKane Tag Attached: fpm
2020-11-02 17:56 TomaszKane Tag Attached: Nginx
2020-11-02 17:56 TomaszKane Tag Attached: PHPStorm
2020-11-02 17:56 TomaszKane File Added: Screenshot_20201102_184329.png
2020-11-02 17:56 TomaszKane File Added: Screenshot_20201102_184346.png
2020-11-02 17:56 TomaszKane File Added: Screenshot_20201102_184537.png
2020-11-03 17:24 derick Assigned To => derick
2020-11-03 17:24 derick Status new => feedback
2020-11-03 17:24 derick Note Added: 0005494
2020-11-10 08:17 TomaszKane Note Added: 0005506
2020-11-10 08:18 TomaszKane Note Added: 0005507
2020-11-10 08:23 TomaszKane Note Added: 0005508
2020-11-10 08:57 TomaszKane Note Added: 0005509
2020-11-14 10:10 derick Note Added: 0005530
2020-12-18 08:42 heil Note Added: 0005594
2020-12-18 08:42 heil Note Added: 0005595
2020-12-30 12:15 derick Status feedback => resolved
2020-12-30 12:15 derick Resolution open => unable to reproduce
2020-12-30 12:15 derick Note Added: 0005624
2021-03-27 13:19 TomaszKane Note Added: 0005817