title: Docker remote daemon (TCP): Cannot connect to the Docker daemon
body: <p>I'm trying to connect a docker daemon from a client to a remote host via TCP but I'm getting this error:</p>
  
  <pre><code>docker -H tcp://{{HOST_IP}}:2375 ps
  
  Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
  </code></pre>
  
  <p>What could be possible reasons for that? What is a proper debugging approach for finding a solution?</p>
  
  <ul>
  <li>System: Ubuntu 18.04 (client and host)</li>
  <li>ufw: enabled for all incoming &amp; outgoing (for testing purposes)</li>
  <li>access rights: working with root on client &amp; host</li>
  </ul>
  
  <p><strong>WHAT I DID</strong></p>
  
  <p><strong>On host:</strong></p>
  
  <pre><code>systemctl edit docker.service
  </code></pre>
  
  <p>Add and save these lines:</p>
  
  <pre><code>[Service]
   ExecStart=
   ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375
  </code></pre>
  
  <p>Reload daemon:</p>
  
  <pre><code>systemctl daemon-reload
  </code></pre>
  
  <p>Restart docker:</p>
  
  <pre><code>systemctl restart docker.service
  </code></pre>
  
  <p>Check if it worked:</p>
  
  <pre><code>netstat -lntp | grep dockerd
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>tcp        0      0 127.0.0.1:2375          0.0.0.0:*               LISTEN      3758/dockerd
  </code></pre>
  
  <p>Test with docker:</p>
  
  <pre><code>docker -H tcp://127.0.0.1:2375 ps
  </code></pre>
  
  <p>Everything worked on the host. However, when I'm trying to connect from the client with the remote host I'm getting an error.</p>
  
  <p><strong>On client:</strong></p>
  
  <pre><code>docker -H tcp://{{HOST_IP}}:2375 ps
  
  Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
  </code></pre>
  
  <p>Connecting via ssh works:</p>
  
  <pre><code>docker -H ssh://root@{{HOST_IP}} ps
  </code></pre>