# IP address for xdebug

**URL:** <https://forums.docker.com/t/ip-address-for-xdebug/10460>\
**Category:** Docker Desktop\
**Tags:** macos\
**Created:** [April 29, 2016, 2:25am UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460 "2016-04-29T02:25:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbrinley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/jbrinley/32/9159_2.png) [@jbrinley](https://forums.docker.com/u/jbrinley)\
**Post date:** [April 29, 2016, 2:25am UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/1 "2016-04-29T02:25:54Z")

</div>

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.`

---

<div class="post-metadata">

**Author:** ![michaelbui](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@michaelbui](https://forums.docker.com/u/michaelbui)\
**Post date:** [May 13, 2016, 12:14pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/2 "2016-05-13T12:14:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dennislampert](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@dennislampert](https://forums.docker.com/u/dennislampert)\
**Post date:** [May 16, 2016, 11:25am UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/3 "2016-05-16T11:25:00Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pjarts](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@pjarts](https://forums.docker.com/u/pjarts)\
**Post date:** [May 30, 2016, 7:24am UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/4 "2016-05-30T07:24:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tancredi](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/tancredi/32/9265_2.png) [@tancredi](https://forums.docker.com/u/tancredi)\
**Post date:** [May 31, 2016, 10:38am UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/5 "2016-05-31T10:38:15Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![jbrinley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/jbrinley/32/9159_2.png) [@jbrinley](https://forums.docker.com/u/jbrinley)\
**Post date:** [May 31, 2016, 12:59pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/6 "2016-05-31T12:59:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![saada](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/saada/32/6236_2.png) [@saada](https://forums.docker.com/u/saada)\
**Post date:** [June 21, 2016, 6:52pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/7 "2016-06-21T18:52:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![m4olivei](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/m4olivei/32/11669_2.png) [@m4olivei](https://forums.docker.com/u/m4olivei)\
**Post date:** [June 22, 2016, 3:35pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/8 "2016-06-22T15:35:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![raeesiqbal](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/raeesiqbal/32/6829_2.png) [@raeesiqbal](https://forums.docker.com/u/raeesiqbal)\
**Post date:** [June 24, 2016, 1:31pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/9 "2016-06-24T13:31:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ladydascalie](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ladydascalie/32/11822_2.png) [@ladydascalie](https://forums.docker.com/u/ladydascalie)\
**Post date:** [June 27, 2016, 3:02pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/10 "2016-06-27T15:02:11Z")

</div>

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)`

---

<div class="post-metadata">

**Author:** ![saada](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/saada/32/6236_2.png) [@saada](https://forums.docker.com/u/saada)\
**Post date:** [June 28, 2016, 2:12pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/11 "2016-06-28T14:12:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jbrinley](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/jbrinley/32/9159_2.png) [@jbrinley](https://forums.docker.com/u/jbrinley)\
**Post date:** [June 28, 2016, 3:07pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/12 "2016-06-28T15:07:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![saada](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/saada/32/6236_2.png) [@saada](https://forums.docker.com/u/saada)\
**Post date:** [June 29, 2016, 2:03pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/13 "2016-06-29T14:03:45Z")

</div>

connect\_back should still be possible on Docker for Mac

---

<div class="post-metadata">

**Author:** ![pjarts](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@pjarts](https://forums.docker.com/u/pjarts)\
**Post date:** [June 29, 2016, 2:08pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/14 "2016-06-29T14:08:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tmatei](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@tmatei](https://forums.docker.com/u/tmatei)\
**Post date:** [June 30, 2016, 5:51pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/15 "2016-06-30T17:51:03Z")

</div>

Same issue here. Has anyone reported this issue?

---

<div class="post-metadata">

**Author:** ![tomasbartkus](https://avatars.discourse-cdn.com/v4/letter/t/5e9695/32.png) [@tomasbartkus](https://forums.docker.com/u/tomasbartkus)\
**Post date:** [July 4, 2016, 8:55am UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/16 "2016-07-04T08:55:59Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![attrox](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@attrox](https://forums.docker.com/u/attrox)\
**Post date:** [July 5, 2016, 3:46pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/17 "2016-07-05T15:46:34Z")

</div>

> [@tomasbartkus](#):
>
> 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

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.

---

<div class="post-metadata">

**Author:** ![milkmedia](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/milkmedia/32/3285_2.png) [@milkmedia](https://forums.docker.com/u/milkmedia)\
**Post date:** [July 6, 2016, 8:55am UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/18 "2016-07-06T08:55:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![raeesiqbal](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/raeesiqbal/32/6829_2.png) [@raeesiqbal](https://forums.docker.com/u/raeesiqbal)\
**Post date:** [July 7, 2016, 9:01pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/19 "2016-07-07T21:01:56Z")

</div>

I have got it working with following configuration:

```auto
; 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

```

```auto
# 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](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en) installed and its `IDE Key` set to `PHPSTORM`.

Happy debugging 🙂

---

<div class="post-metadata">

**Author:** ![ddinchev](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ddinchev/32/12165_2.png) [@ddinchev](https://forums.docker.com/u/ddinchev)\
**Post date:** [July 8, 2016, 4:59pm UTC](https://forums.docker.com/t/ip-address-for-xdebug/10460/20 "2016-07-08T16:59:00Z")

</div>

+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.

[Next page](https://forums.docker.com/t/ip-address-for-xdebug/10460.md?page=2)
