Skip to content
FR
  1. LuzineDebug
  2. Docker & DevOps
  3. Cannot connect to the Docker daemon at unix:///v…
Docker & DevOps Beginner ≈ 5 min to fix

Fix "Cannot connect to the Docker daemon. Is the docker daemon running?"

Error message
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
  • Cannot connect to the Docker daemon at unix:///Users/me/.docker/run/docker.sock. Is the docker daemon running?
  • Cannot connect to the Docker daemon at unix:///Users/me/.colima/default/docker.sock. Is the docker daemon running?
  • failed to connect to the docker API at unix:///var/run/docker.sock; check if the path is correct and if the daemon is running: dial unix /var/run/docker.sock: connect: no such file or directory
  • error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.47/containers/json": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.
  • Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
In short

The docker client finds no engine at the address it uses: Docker Desktop, Colima or OrbStack is not running, or the docker service is stopped on Linux. Start the engine (sudo systemctl start docker on Linux, open Docker Desktop on macOS and Windows), then check with docker context ls that the CLI targets the right context.

Be the first to confirm this fix

What this error means

The docker command is only a client: it sends requests to the dockerd daemon API, through a Unix socket (/var/run/docker.sock on Linux, ~/.docker/run/docker.sock with Docker Desktop on macOS), a named pipe on Windows or a TCP address. Here the connection itself fails: the socket file does not exist (no such file or directory) or nothing listens behind it (connection refused). The daemon is stopped, the VM hosting it is off, or the CLI points elsewhere because of the active context or DOCKER_HOST. Do not confuse it with "permission denied", where the daemon runs but access to the socket is refused.

Common causes

  1. Docker Desktop not running (macOS, Windows): after a reboot the app does not start on its own, or the engine is still starting.
  2. Service stopped on Linux: docker.service is not enabled at boot, or it crashed on start (often an invalid /etc/docker/daemon.json).
  3. Wrong context or stale DOCKER_HOST: you switched from Docker Desktop to Colima or OrbStack (or back), or an export DOCKER_HOST=... line in ~/.zshrc points to an engine that no longer exists.
  4. Colima, OrbStack or Podman VM stopped, or a tool (Testcontainers, IDE) that looks for /var/run/docker.sock while the socket lives elsewhere.
  5. WSL2: Docker Desktop’s WSL integration is disabled for the distribution, or Docker Engine is installed inside WSL without systemd to start it.

Step-by-step fix

  1. See which engine the CLI is trying to reach

    The context marked with * is the one in use, and its DOCKER ENDPOINT must match the engine you installed. If DOCKER_HOST is set, it overrides the context. docker version shows no Server section while the daemon is unreachable.

    bash
    docker context ls
    echo "$DOCKER_HOST"
    docker version
  2. Linux: start and enable the service

    Start the daemon and enable it at boot. If it refuses to start, read its journal and validate daemon.json: one extra comma is enough to stop it. Without systemd (older WSL distributions, some containers), use sudo service docker start.

    bash
    sudo systemctl enable --now docker
    systemctl status docker --no-pager
    sudo journalctl -u docker --no-pager -n 50
    sudo dockerd --validate --config-file /etc/docker/daemon.json
  3. macOS and Windows: start Docker Desktop

    Open Docker Desktop and wait for the "Engine running" state. On Windows, launch it from the Start menu. Then select its context, desktop-linux. If a tool requires /var/run/docker.sock on macOS, enable "Allow the default Docker socket to be used" in Settings > Advanced.

    bash
    open -a Docker
    docker context use desktop-linux
    docker info --format '{{.ServerVersion}}'
  4. Colima or OrbStack: start the VM and its context

    These tools create their own context. Start the VM, then select the matching context. For tools that do not read contexts, export DOCKER_HOST to the Colima socket.

    bash
    colima start
    docker context use colima
    export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
    
    orb start
    docker context use orbstack
  5. Clean up a stale DOCKER_HOST

    If DOCKER_HOST points to an engine you no longer use, remove the variable from the session and the matching line in ~/.zshrc or ~/.bashrc, then go back to the default context. Prefer contexts over DOCKER_HOST: they switch without editing your shell.

    bash
    unset DOCKER_HOST
    grep -n DOCKER_HOST ~/.zshrc ~/.bashrc 2>/dev/null
    docker context use default
  6. WSL2: integration or systemd

    With Docker Desktop, enable your distribution in Settings > Resources > WSL integration. With Docker Engine installed directly inside WSL, enable systemd in /etc/wsl.conf, run wsl --shutdown from PowerShell, reopen the distribution, then sudo systemctl enable --now docker.

    ini
    [boot]
    systemd=true

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Enable automatic start: systemctl enable docker on Linux, the "Start Docker Desktop when you sign in" option on macOS and Windows.
  • Keep a single engine active at a time and switch with docker context use, rather than with a DOCKER_HOST frozen in your shell profile.
  • In CI, wait for the daemon to answer before the first command, for example with an until docker info >/dev/null 2>&1; do sleep 1; done loop.

Frequently asked questions

What is the difference with "permission denied while trying to connect to the Docker daemon socket"?

"Cannot connect" means the daemon is unreachable (stopped or wrong address). "Permission denied" means it runs, but your user is not allowed to open the socket: that is a docker group issue.

Docker Desktop is running but the error remains, why?

The CLI probably targets another engine: check docker context ls and DOCKER_HOST. If everything looks right, restart Docker Desktop (Troubleshoot menu > Restart) to recreate the socket.

How do I fix "Cannot connect to the Docker daemon at tcp://docker:2375" in GitLab CI?

The job uses Docker-in-Docker without the service. Add services: [docker:dind] to the job; with TLS (the default), set DOCKER_HOST: tcp://docker:2376 and DOCKER_TLS_CERTDIR: "/certs", and use a runner allowed to run in privileged mode.

Useful tools for this error

More Docker & DevOps errors

All Docker & DevOps errors →