Fix for “Cannot connect to the Docker daemon”

One of the reasons I keep finding my way back to my Linux machine is when I’m doing work using Docker. On Windows, I have a fairly rich (at least I think it is) integration with WSL and Windows and things work great. Except…VS Code and git issues with file properties and WSL randomly can’t connect to the Docker daemon. The first issue may have just been fixed over time by new releases of WSL, I’m still testing that out. But for the second one, I finally found a fix!

I have everything for WSL/Docker integration set up just fine (if you need help with that, check here.) However, for some reason it fails to connect to the daemon with “Cannot connect to the docker daemon at tcp://0.0.0.0:2375” message.

Windows can’t connect using that host address, either, so I knew it wasn’t an issue with WSL. My guess was that it was due to a VPN and/or firewall setting, but due to corporate policy on that machine I couldn’t muck with it to test. Now I don’t have to, because I stumbled across this Docker forum post suggesting to run a container that forwards another port, such as 23750, to 2375. Genius, and works like a charm!

Hopefully this helps someone else who’s having a similar issue, even if that someone is me next year when I forget how to fix it. 🙂

2 thoughts on “Fix for “Cannot connect to the Docker daemon””

  1. Alex R says:

    Hi Thanks.

    I’m having a similar issue in Vscode with WSL 2 Ubuntu 18.04.

    Any tips?


    Client:
    Debug Mode: false

    Server:
    ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
    errors pretty printing info

    1. Ryan McIntyre says:

      Could be one of a few things, probably not related to this post by now, though. Have you had any luck figuring it out? When you say “in Vscode”, do you mean you’re seeing that error in the terminal window inside VS Code?

Leave a Reply

Your email address will not be published. Required fields are marked *