Fix "Cannot connect to the Docker daemon. Is the docker daemon running?"
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?
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.
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
- Docker Desktop not running (macOS, Windows): after a reboot the app does not start on its own, or the engine is still starting.
- Service stopped on Linux:
docker.serviceis not enabled at boot, or it crashed on start (often an invalid/etc/docker/daemon.json). - Wrong context or stale
DOCKER_HOST: you switched from Docker Desktop to Colima or OrbStack (or back), or anexport DOCKER_HOST=...line in~/.zshrcpoints to an engine that no longer exists. - Colima, OrbStack or Podman VM stopped, or a tool (Testcontainers, IDE) that looks for
/var/run/docker.sockwhile the socket lives elsewhere. - 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
-
See which engine the CLI is trying to reach
The context marked with
*is the one in use, and itsDOCKER ENDPOINTmust match the engine you installed. IfDOCKER_HOSTis set, it overrides the context.docker versionshows noServersection while the daemon is unreachable.docker context ls echo "$DOCKER_HOST" docker version -
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), usesudo service docker start.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 -
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.sockon macOS, enable "Allow the default Docker socket to be used" in Settings > Advanced.open -a Docker docker context use desktop-linux docker info --format '{{.ServerVersion}}' -
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_HOSTto the Colima socket.colima start docker context use colima export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock" orb start docker context use orbstack -
Clean up a stale DOCKER_HOST
If
DOCKER_HOSTpoints to an engine you no longer use, remove the variable from the session and the matching line in~/.zshrcor~/.bashrc, then go back to the default context. Prefer contexts overDOCKER_HOST: they switch without editing your shell.unset DOCKER_HOST grep -n DOCKER_HOST ~/.zshrc ~/.bashrc 2>/dev/null docker context use default -
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, runwsl --shutdownfrom PowerShell, reopen the distribution, thensudo systemctl enable --now docker.[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 dockeron 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 aDOCKER_HOSTfrozen 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; doneloop.
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
- Fix "permission denied while trying to connect to the Docker daemon socket"
- Fix "Bind for 0.0.0.0:8080 failed: port is already allocated" (Docker)
- Fix "no space left on device" (Docker and Linux)
- Fix "exec format error" in Docker (arm64 / amd64)
- Fix "connect() failed (111: Connection refused) while connecting to upstream" (Nginx 502)
- Fix "exited with code 137" (OOMKilled) in Docker and Kubernetes
- Fix "CrashLoopBackOff" / "Back-off restarting failed container" (Kubernetes)