I've been struggling with this for some time and here I am :-)
I have a php container with xdebug installed in a Ubuntu 20.04 laptop:
rest-example-php-8:
container_name: rest-php
build: ./docker/php/
expose:
- 9000
depends_on:
- rest-example-mysql
- rest-example-redis
volumes:
- .:/var/www/html
- ./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
extra_hosts:
- "host.docker.internal:host-gateway"
The build file:
FROM php:8.0-fpm
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
And the xdebug configuration
[xdebug]
xdebug.mode=debug
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.discover_client_host=true
xdebug.client_host=host.internal.docker
xdebug.idekey=PHPSTORM
xdebug.log = "/var/log/xdebug.log"
xdebug.output_dir = "/var/log/profiler"
When I try to execute any php script either with phpstorm or direcly in the container with bash I get this error:
Xdebug: [Step Debug] Could not connect to debugging client. Tried: fe80:0:0:0:e898:eeff:fefb:e968%vetha93964b:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
That's with PHP storm, if I do it directly in the container:
Could not connect to debugging client. Tried: host.internal.docker:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
Things that I've tried:
Change client host. I've tried ips and hostnames, no success
Open my 9003 port in my host machine, according to nmap is open:
nmap localhost Starting Nmap 7.80 ( https://nmap.org ) at 2021-08-04 19:53 CEST Nmap scan report for localhost (127.0.0.1) Host is up (0.000061s latency). Not shown: 998 closed ports PORT STATE SERVICE 631/tcp open ipp 9003/tcp open unknown
I also checked that is PHP Storm who is listening
sudo lsof -i -P -n | grep LISTEN | grep 9003
java 4566 myuser 54u IPv6 543552 0t0 TCP *:9003 (LISTEN)
And the problem seems to be in the host machine, I also tried to access the 9003 of the host from the container with no success.
Anyone knows what can be going on and what else could I test? Any help would be much appreciated :-)