Docker Community Forums

Share and learn in the Docker community.

IP address for xdebug

You can use as xdebug.remote_host in the xdebug.ini file

still broken in 1.12.1-beta24 . setting a remote host works, but i think it is important to use remote connect back, so this will work on different environments like toolbox-mac, docker mac, linux …

I tried doing this… but then what IP/interface do you listen on inside the IDE? (In this case, PhpStorm)

Man I have looked through so many Docker forum and StackOverflow posts but can’t seem to get it to work. Does somebody mind looking at our setup and finding the problem?

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 used to work for me using the Docker for Mac beta, but after updating to v1.12.1 stable, the mentioned file no longer exists…

Is there any way to get this IP without setting up a loopback IP? If not, there should be.

I used to use the loopback alias. It works great but if you don’t have any network connection (no wifi), the connection between xdebug and the host can’t be established.

Has someone an idea on how to resolve this ? and ensure that the connection will work even if you work offline ?


Instead of creating loopback workaround, you can also use ssh tunnel with this configuration:
xdebug.remote_connect_back = 0
Posted full solution here

After much pain I got this working with the following:

RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y \
    && apt-get install -y git curl \
    && pecl install xdebug \
    && rm -rf /tmp/pear \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name\n"
       >> /usr/local/etc/php/conf.d/xdebug.ini


xdebug.idekey = PHPSTORM
xdebug.default_enable = 0
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.profiler_enable = 1

sudo ifconfig en0 alias

I wrote up and recorded my workflow here: Debugging PHP apps

Hope this helps someone.

On a windows host, I got this to work by using the IPv4 address used by the vEthernet (DockerNAT) connection. Just check your network connections, view that specific connection’s details to get the ip address and plug that into your xdebug.remote_host. I also had to enable remote_autostart (for some reason, I could never get xdebug to trigger using GET/POST/cookies)

1 Like

Thank you for suggestion about DockerNAT address on Windows 10 host. Also, for me following configuration was enough:

I wrote that for our company php image, it can be useful for someone:

Alright, I’d like to add my two cents to this excellent thread.

So, normally, you could set xdebug.remote_connect_back=on in order for Xdebug to connect to any client that makes a request to the server regardless of hostname/IP. When this is on, the xdebug.remote_host setting is ignored.

For whatever reason, Docker for Mac prevents Xdebug from allowing such unrestricted connections. One reason could be because when you enable xdebug.remote_connect it tries to connect to, which is the IP of the request according to the container, probably due to how Docker for Mac integrates the networking of the host and container. As a result, it thinks that the request is coming from the container rather than the host. I’m not totally sure if this is what’s happening, but it’s my best guess.

I, like pretty much everyone else here, could not get Xdebug to work with such a Docker for Mac container until I disabled xdebug.remote_connect_back.

It would appear that you can set xdebug.remote_host to any hostname/IP that your host computer is identified by, not the IP that the container uses to identify your host, which typically starts with 172. You can set an alias IP on your host if you want, but it would appear that you can likewise use an IP already assigned to the host on the local network. In fact, Docker has a brief Xdebug tutorial where they do this. I was confused by their instructions to use the host’s private IP because in other containers, like Vagrant and Docker via VirtualBox, you do have to set xdebug.remote_host to the IP that the container identifies the host with, which is typically the the gateway IP of the container, or the one seen in the access logs.

And so, my working Xdebug config on a Docker for Mac container is simply the following:

xdebug.remote_host= # My host's IP on en1
xdebug.remote_port=9001 # 9000 is already in use on my host and therefore unavailable for the container
1 Like

Thanks for this excellent thread - I’ve been struggling with with the same XDebug problem with mac and PHPStorm and stumbled on to a slightly better way to setup your php.ini if you’re using Docker For Mac 17.06+:


At least this eliminates a static IP which is annoying if you’re on DHCP. I’m working on a new image that will hopefully be able to do a detection if it’s Docker For Mac or not and setup the php.ini this way if so, otherwise use remote_connect_back.


Thank you! Work perfect :slight_smile:

This really helped me! Specifically the xdebug.remote_host=docker.for.mac.localhost part. Any ideas what this means?

1 Like

nice, it’s works.

Here are some general instructions regardless of Docker on Linux, Docker for Windows, Docker for Mac or Docker Toolbox:

Using: Netbeans 8.2, Docker Toolbox on Mac, PHP7.2
Here’s how it worked for me after three hours of trying various ideas above:

On Mac host, run sudo ifconfig lo0 alias

In php.ini (in my case, xdebug.ini inside conf.d), use:

xdebug.idekey=netbeans-xdebug (or PHPSTORM, or whatever – just needs to match in IDE setup)

In the project run configuration, I use a "Local Web Site (running on local web server) that points to the URL I have in my hosts file that points to (docker container IP).

The advanced settings (path mapping and debugger proxy) got me sidetracked for a while. I didn’t need these as a local docker container isn’t truly a remote server.

Good luck. Time for another sip of Monster.

Hello there,

You no longer need to setup a lo0 alias, the nice host.docker.internal is working like a charm on docker for mac.

Try following configuration:
xdebug.remote_connect_back = 0
xdebug.remote_host = host.docker.internal


The fastcgi_param REMOTE_ADDR was the missing piece for me. Set both it and xdebug.remote_host to my host machines eth0 address and viola! xdebug breakpoints are working in vscode! - Thanks for the insight @raeesiqbal