IP address for xdebug

I have an nginx container and a php-fpm container running together as my web server. I connect to it through a container running jwilder/nginx-proxy that exposes port 80. On beta8, xdebug was able to connect back to PhpStorm running on my Mac host. With beta9, it cannot.

As a temporary workaround, I’ve setup another loopback IP on my host:

sudo ifconfig lo0 alias 10.254.254.254

And in php.ini, I’ve set:

xdebug.remote_host=10.254.254.254

Is there another way to make this work besides setting up the new global IP address? Is there an address that services running in containers can use to reach back to the host?

Expected behavior

When xdebug.remote_connect_back=1 in php.ini, xdebug connects back to the Mac rather than to itself.

Actual behavior

The xdebug logs report:

Log opened at 2016-04-29 02:12:12 I: Checking remote connect back address. I: Checking header 'HTTP_X_FORWARDED_FOR'. I: Remote address found, connecting to 172.17.0.1:9090. E: Could not connect to client. :-( Log closed at 2016-04-29 02:12:12

Information

$ pinata diagnose -u OS X: version 10.11.4 (build: 15E65) Docker.app: version v1.11.0-beta9 Running diagnostic tests: [OK] docker-cli [OK] Moby booted [OK] driver.amd64-linux [OK] vmnetd [OK] osxfs [OK] db [OK] slirp [OK] menubar [OK] environment [OK] Docker [OK] VT-x Docker logs are being collected into /tmp/20160428-222036.tar.gz Most specific failure is: No error was detected Your unique id is: DE98ED6A-CF8C-42C0-B387-CB3A5C604478 Please quote this in all correspondence.

12 Likes

I got same issue. Tried to set IP as 172.17.0.1 but still can’t connect to my PHPStorm :frowning:

1 Like

Same here! Works perfect when I’m running docker on a VM. But now it doesn’t work for any ip when i run docker for mac. I install the xdebug in my container running the php server. Else it’s working very well so far!

Same issue here. I was able to connect to PHPStorm on 172.17.42.1 but it was amazingly slow. 172.17.0.1 doesn’t work at all. However, I have the same problem with docker-machine so I guess it’s not a problem specific to the docker for mac beta. I run 1.11.1 on both docker-machine and osx.

I can confirm this is still an issue with beta13.1. Using jbrinley’s loopback workaround does work so at least this is possible.

As stated you need to run on your host:

sudo ifconfig lo0 alias 10.254.254.254

Then in your php.ini:
xdebug.remote_host=10.254.254.254
xdebug.remote_connect_back = 0

The remote_connect_back must be disabled for remote_host to be used.

OS X: version 10.11.5 (build: 15F34)
Docker.app: version v1.11.1-beta13.1
Running diagnostic tests:
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
Docker logs are being collected into /tmp/20160531-112333.tar.gz
Most specific failure is: No error was detected
Your unique id is: 80AF3F1D-B9D8-4F5A-A209-BEA8649FE954
3 Likes

As mentioned in my original post, I’m connecting to my containers via jwilder/nginx-proxy. I’ve found that a tweak there makes this slightly less cumbersome.

You still have to setup the loopback IP:

sudo ifconfig lo0 alias 10.254.254.254

And in the proxy’s config (mapping a local file onto /app/nginx.tmpl), I change

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

to

proxy_set_header X-Forwarded-For 10.254.254.254;

This allows xdebug.remote_connect_back to work correctly, so I don’t have to set my connect back IP address in more than one place.

1 Like

This is happening in Docker for Mac 1.12.0-rc2-beta16 (build: 9493) as well

Also seeing the issue on Docker for Mac version 1.12.0-rc2. I can get it to work by setting the xdebug.remote_host to the internal IP on my Macbook, but that’s not ideal since it requires a manual step. It would be nice to be able to use the gateway IP, b/c that could be scripted in the Dockerfile.

I could not make this work on Docker for Mac 1.12.0-rc2-beta16. There should a tutorial explaining the steps.

1 Like

Normal configuration yields port conflicts (it worked through docker-machine), and workaround gives me the same issue as @raeesiqbal is experiencing.

I’m on: Version 1.12.0-rc2-beta16 (build: 9493)

I could’ve sworn xdebug was working in beta14 and beta15.
Should we create a github issue for this?

Still working for me, using the workarounds posted above, on 1.12.0-rc2-beta16.

connect_back should still be possible on Docker for Mac

Same issue here. Version 1.12.0-rc2-beta16 on OS X 10.11.5

Same issue here. Has anyone reported this issue?

Try IP from here as xdebug.remote_host : cat /Users/<YOUR_USERNAME>/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/slirp/host

3 Likes

This works! Thank you.
I just modified
xdebug.remote_connect_back=0
xdebug.remote_host=[IP ADDRESS FROM host mentioned above]

And everything works now. Thank you again, it took me days to get this working.

I set the xdebug.remote_host and set PhpStorm to listen for connections but still not seeing anything. The new xdebug settings show up in a phpinfo page, so they are defiantly in effect.

I have got it working with following configuration:

; xdebug options for HHVM/PHP
xdebug.enable=1
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.idekey="PHPSTORM"
xdebug.remote_host="192.168.1.5" ; My local network IP, which is accessiable inside the container
xdebug.remote_port=9089
# NGINX config, set this where you have put other FastCGI configuration
fastcgi_param REMOTE_ADDR "192.168.1.5"; #My local network IP

Make sure to restart the containers after these.

Now goto PHPStorm Preferences -> Languages and Frameworks -> PHP -> Debug:
In the Xdebug section, set Debug port to 9089 and Can accept external connections should be checked. Now, click on the phone icon in top right corner in PHPStorm that has caption of Start listening for PHP debug connections.
You may want to restart PHPStorm and should have XDebug Helper installed and its IDE Key set to PHPSTORM.

Happy debugging :slight_smile:

1 Like

+1. I’ve tried unsuccessfully to make it work with 1.12.0-rc3 using the internal container IP where connections come from - 172.19.0.1. The solution using the local IP address works but is extremely annoying when working from several different places and changing IP.