title: How can I get VSCode to connect to Xdebug with Docker
body: <p>PHP version:  7.2<br>
  Xdebug version: 2.6.0<br>
  Adapter version:  1.12.1<br>
  Example Repo: <a href="https://github.com/makeshift3ds/vscode-xdebug-docker" rel="nofollow noreferrer">https://github.com/makeshift3ds/vscode-xdebug-docker</a></p>
  
  <p>I am having trouble getting VSCode to connect to Xdebug running in Docker. I've followed examples and tutorials but feel like something is missing. </p>
  
  <p>Notes:
  - if I start the debugger in VSCode, the debugger output says <code>success: true</code> in the object. But the xdebug logs in the docker container show no activity. However, if I run the PHP script from the php-fpm container Xdebug logs look healthy.</p>
  
  <pre><code>Log opened at 2018-03-13 15:29:11
  I: Checking remote connect back address.
  I: Checking header 'HTTP_X_FORWARDED_FOR'.
  I: Checking header 'REMOTE_ADDR'.
  I: Remote address found, connecting to 172.18.0.1:9001.
  I: Connected to client. :-)
  -&gt; &lt;init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/index.php" language="PHP" xdebug:language_version="7.2.3" protocol_version="1.0" appid="7" idekey="VSCODE"&gt;&lt;engine version="2.6.0"&gt;&lt;![CDATA[Xdebug]]&gt;&lt;/engine&gt;&lt;author&gt;&lt;![CDATA[Derick Rethans]]&gt;&lt;/author&gt;&lt;url&gt;&lt;![CDATA[http://xdebug.org]]&gt;&lt;/url&gt;&lt;copyright&gt;&lt;![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]&gt;&lt;/copyright&gt;&lt;/init&gt;
  
  -&gt; &lt;response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"&gt;&lt;/response&gt;
  
  Log closed at 2018-03-13 15:29:11
  </code></pre>
  
  <ul>
  <li><p>if I attempt a connection in VSCode and try to evaluate some code it says there is no connection.</p></li>
  <li><p>php-fpm is running on port 9000 so I setup Xdebug on 9001. I can see the ports are open.</p></li>
  </ul>
  
  <p>-</p>
  
  <pre><code>vpnkit          59029 makeshift   19u     IPv4 0x7784b9d434951b53        0t0     TCP *:9001 (LISTEN)
  vpnkit          59029 makeshift   20u     IPv6 0x7784b9d42c30a203        0t0     TCP [::1]:9001 (LISTEN)
  Code\x20Helper  99786 makeshift   27u     IPv6 0x7784b9d42c30bec3        0t0     TCP *:9001 (LISTEN)
  </code></pre>