# Xdebug on docker with PhpStorm doesn't work

**URL:** <https://forums.docker.com/t/xdebug-on-docker-with-phpstorm-doesnt-work/22858>\
**Category:** Compose\
**Tags:** docker\
**Created:** [October 2, 2016, 9:38am UTC](https://forums.docker.com/t/xdebug-on-docker-with-phpstorm-doesnt-work/22858 "2016-10-02T09:38:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksiamro](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@ksiamro](https://forums.docker.com/u/ksiamro)\
**Post date:** [October 2, 2016, 9:38am UTC](https://forums.docker.com/t/xdebug-on-docker-with-phpstorm-doesnt-work/22858/1 "2016-10-02T09:38:15Z")

</div>

Hello,

Im quite new in Docker.  
I can’t connect xdebug on docker container to phpstorm ide.

My PhpStorm is v 8.0.3

I spend a lot of time for searching how to solve with negative result.  
I’m pretty sure I tried everything I found and bit more solution.

My actual docker-compose snip:

> ports:
> 
> - “8081:8081”
> - “80:80”
> - “443:443”  
> expose:
> - “9001”  
> links:
> - magedb\_m1  
> environment:  
> XDEBUG\_CONFIG: “remote\_host=172.17.0.1”  
> PHP\_IDE\_CONFIG: “serverName=docker”  
> XDEBUG\_CONFIG: “idekey=PHPSTORM”  
> PHP\_XDEBUG\_ENABLED: 1  
> volumes:
> - ./project/:/var/www/html/

xdebug.ini:

> [xdebug]

> zend\_extension=xdebug.so  
> xdebug.idkey = “PHPSTORM”

> xdebug.default\_enable=1  
> xdebug.remote\_enable=1  
> xdebug.remote\_handler=dbgp  
> ; This is the default Docker gateway  
> xdebug.remote\_host=172.17.0.1  
> xdebug.remote\_port=9001  
> xdebug.remote\_autostart=1  
> xdebug.remote\_connect\_back=0

Phpstorm PHP settings:

> **[Featured Posts - Amirite](https://www.amirite.com)**
>
> Find out who agrees with you. Post your thoughts and instantly be told if you are right!

ip a from my local:

> 1: lo: \<LOOPBACK,UP,LOWER\_UP\> mtu 65536 qdisc noqueue state UNKNOWN  
> link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
> inet 127.0.0.1/8 scope host lo  
> valid\_lft forever preferred\_lft forever  
> inet6 ::1/128 scope host  
> valid\_lft forever preferred\_lft forever  
> 2: enp4s0f1: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc pfifo\_fast state UP qlen 1000  
> link/ether 14:dd:a9:0b:ee:74 brd ff:ff:ff:ff:ff:ff  
> inet 192.168.2.104/24 brd 192.168.2.255 scope global dynamic enp4s0f1  
> valid\_lft 315356022sec preferred\_lft 315356022sec  
> inet6 fe80::16dd:a9ff:fe0b:ee74/64 scope link  
> valid\_lft forever preferred\_lft forever  
> 3: virbr0: \<NO-CARRIER,BROADCAST,MULTICAST,UP\> mtu 1500 qdisc noqueue state DOWN  
> link/ether 52:54:00:d5:ef:9c brd ff:ff:ff:ff:ff:ff  
> inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0  
> valid\_lft forever preferred\_lft forever  
> 4: virbr0-nic: \<BROADCAST,MULTICAST\> mtu 1500 qdisc pfifo\_fast master virbr0 state DOWN qlen 500  
> link/ether 52:54:00:d5:ef:9c brd ff:ff:ff:ff:ff:ff  
> 5: docker0: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc noqueue state UP  
> link/ether 02:42:b4:ad:cc:ab brd ff:ff:ff:ff:ff:ff  
> inet 172.17.0.1/16 scope global docker0  
> valid\_lft forever preferred\_lft forever  
> inet6 fe80::42:b4ff:fead:ccab/64 scope link  
> valid\_lft forever preferred\_lft forever  
> 6: br-c2e824564ce6: \<NO-CARRIER,BROADCAST,MULTICAST,UP\> mtu 1500 qdisc noqueue state DOWN  
> link/ether 02:42:44:61:39:53 brd ff:ff:ff:ff:ff:ff  
> inet 172.18.0.1/16 scope global br-c2e824564ce6  
> valid\_lft forever preferred\_lft forever  
> 34: veth29f09f2@if33: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc noqueue master docker0 state UP  
> link/ether da:96:0c:3e:78:bd brd ff:ff:ff:ff:ff:ff link-netnsid 0  
> inet6 fe80::d896:cff:fe3e:78bd/64 scope link  
> valid\_lft forever preferred\_lft forever  
> 36: vethddad676@if35: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc noqueue master docker0 state UP  
> link/ether 2e:26:7c:1b:7c:0b brd ff:ff:ff:ff:ff:ff link-netnsid 1  
> inet6 fe80::2c26:7cff:fe1b:7c0b/64 scope link  
> valid\_lft forever preferred\_lft forever

ip a from container with xdebug

> 1: lo: \<LOOPBACK,UP,LOWER\_UP\> mtu 65536 qdisc noqueue state UNKNOWN group default  
> link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
> inet 127.0.0.1/8 scope host lo  
> valid\_lft forever preferred\_lft forever  
> inet6 ::1/128 scope host  
> valid\_lft forever preferred\_lft forever  
> 35: eth0@if36: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc noqueue state UP group default  
> link/ether 02:42:ac:11:00:03 brd ff:ff:ff:ff:ff:ff link-netnsid 0  
> inet 172.17.0.3/16 scope global eth0  
> valid\_lft forever preferred\_lft forever  
> inet6 fe80::42:acff:fe11:3/64 scope link  
> valid\_lft forever preferred\_lft forever

On container xdebug.ini exist in:  
etc/php/5.6/mods-available/xdebug.ini

I tried different remote host address (172.17.0.3 / 172.17.0.2 / 172.17.41.1 / much more).  
Different xdebug.ini options

Can You give me a tip how to solve it?

Regards,  
Konrad

---

<div class="post-metadata">

**Author:** ![elmudo](https://avatars.discourse-cdn.com/v4/letter/e/8dc957/32.png) [@elmudo](https://forums.docker.com/u/elmudo)\
**Post date:** [August 8, 2017, 9:27am UTC](https://forums.docker.com/t/xdebug-on-docker-with-phpstorm-doesnt-work/22858/2 "2017-08-08T09:27:04Z")

</div>

The problem is with Docker for Mac. All you need to do to get xdebug working is to use:  
`xdebug.remote_host=docker.for.mac.localhost`  
The issue is documented here:

> **[Networking features in Docker for Mac](https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds)**
>
> Docker for Mac provides several networking features to make it easier to use. Features VPN Passthrough Docker for Mac’s networking can work when attached to a VPN. To do this,...

  
My xdebug.ini is:

```
xdebug.remote_enable=1
xdebug.remote_connect_back=0
; remote_host:
; You can use 172.17.0.1 if you don't use a Mac or when Docker/Apple fix the network problem.
xdebug.remote_host=docker.for.mac.localhost
; remote_port:
; Yes, this can be the same port number as PHP-FPM uses to *listen* on - they are on different servers
xdebug.remote_port=9000
; idekey:
; Anything you want. Just make sure the same value is sent from the browser or CLI.
xdebug.idekey=phpstorm
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so

```

Good luck,  
Conor

---

<div class="post-metadata">

**Author:** ![cytopia](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/cytopia/32/13743_2.png) [@cytopia](https://forums.docker.com/u/cytopia)\
**Post date:** [July 26, 2018, 12:18pm UTC](https://forums.docker.com/t/xdebug-on-docker-with-phpstorm-doesnt-work/22858/3 "2018-07-26T12:18:13Z")

</div>

For general info about configuring PHP and your IDE in a dockerized environment, have a look at this documentation: [https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug.html](https://devilbox.readthedocs.io/en/latest/intermediate/configure-php-xdebug.html)
