Fix "Cannot Connect to the Docker Daemon"
The daemon error almost never means Docker is broken. Nine times out of ten it's a stopped service, a stale context, or a wrong env var. Here's the checklist.
Key takeaways
- The error means the Docker CLI could not reach a daemon at the socket it is aimed at.
- Check echo $DOCKER_HOST and docker context ls first, because a stale target is common.
- Then run sudo systemctl start docker, and if it will not start, read journalctl -u docker for the real cause.
- Reinstalling is almost never needed.
On this page
"Cannot connect to the Docker daemon at unix:///var/run/docker.sock" means the CLI reached no daemon at that socket. Check where it points with echo $DOCKER_HOST and docker context ls, then start the daemon with sudo systemctl start docker. If it refuses to start, journalctl -u docker names the cause. Do not reinstall.
Verified against
Docker Engine 29.9 (29.9.2, released 2026-10-20), against the docs.docker.com daemon troubleshooting, Docker contexts, rootless mode and Docker Desktop WSL pages. Checked October 2026.
This is the message:
$ docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
This shows up on fresh laptops, in CI runners, and over SSH on boxes with forgotten client configuration. It reads like something is badly broken. It almost never is. The CLI is a thin client that sends API calls to dockerd over a socket, and this error means the client could not reach that socket. Docker's troubleshooting page gives two causes: the daemon is not running, or the client points at a host it cannot reach. Every fix below answers one question: which daemon should I be talking to, and is it up?
The four-command diagnosis
Run these before changing anything. The first two catch "the client is pointed wrong", the last two catch "the daemon is down":
$ echo $DOCKER_HOST # is the client aimed somewhere odd?
$ docker context ls # which endpoint is active (marked *)?
$ systemctl status docker # is the daemon up? (add --user for rootless)
$ sudo journalctl -u docker --no-pager -n 40 # if it won't start, why?
docker info is the OS-independent check the docs recommend: if it prints a Server: section, the client reached a daemon.
First, check where the client is pointing
If DOCKER_HOST is set to something you do not recognize (an old tcp:// address, a remote box that is gone), that is your answer. It often survives in a .bashrc from a tutorial followed long ago.
$ echo $DOCKER_HOST
tcp://10.0.4.12:2375
$ unset DOCKER_HOST
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
If that works, delete the export from your shell profile so it does not return tomorrow. docker context ls shows the same thing from the other side; the active context has a *:
$ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT
default Current DOCKER_HOST based unix:///var/run/docker.sock
desktop-linux * Docker Desktop unix:///home/me/.docker/desktop/docker.sock
$ docker context use default
This bites people who install Docker Desktop and later the native engine, or the reverse: the context is left pointing at a socket nobody serves. The contexts docs note that environment variables such as DOCKER_HOST and DOCKER_CONTEXT override the active context, so clear them first or the use command appears to do nothing.
Then check whether the daemon is running
On Linux with the native engine, the daemon is a systemd service:
$ systemctl status docker
○ docker.service - Docker Application Container Engine
Active: inactive (dead)
$ sudo systemctl enable --now docker
$ docker info --format '{{.ServerVersion}}'
29.9.2
enable --now starts it and makes it come back after a reboot, which is the most common way "it worked yesterday" returns. If /var/run/docker.sock does not exist at all, that is the same problem: no daemon has created it yet.
If the service loops in activating or lands in failed, do not guess. Read the journal; the cause is nearly always in the last twenty lines. A trailing comma in /etc/docker/daemon.json, an unsupported storage driver, or a flag conflict all show up there.
The flag conflict deserves its own example, because it catches anyone who adds "hosts" to daemon.json on a systemd distro where the unit already passes -H. This is the error as Docker's troubleshooting page shows it:
unable to configure the Docker daemon with file /etc/docker/daemon.json:
the following directives are specified both as a flag and in the
configuration file: hosts: (from flag: [unix:///var/run/docker.sock], from file: [tcp://127.0.0.1:2376])
The documented fix is a systemd drop-in that clears the unit's ExecStart so the flag goes away, then a reload:
# /etc/systemd/system/docker.service.d/docker.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
On Docker Desktop (Mac, Windows, or Linux) there is no system service to poke. The daemon lives in Desktop's VM, and if Desktop is not running the socket is not served. Start the app, wait until it reports the engine running, then retry.
Rootless and WSL2, the two setups that trip everyone
Rootless Docker does not use /var/run/docker.sock. The daemon runs as your user and the socket lives under your runtime directory, managed by a user-level systemd unit:
$ systemctl --user start docker
$ export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock
$ docker info | grep -A4 'Security Options'
A rootless daemon lists rootless under Security Options, next to seccomp and cgroupns.
Note the --user. sudo systemctl status docker tells you nothing about a rootless daemon, which is why people conclude "the unit doesn't exist."
WSL2 has its own trap. If the CLI runs inside a WSL2 distro and talks to Docker Desktop on Windows, the link is Desktop's WSL integration, a per-distro toggle. Open Desktop, go to Settings, Resources, WSL Integration, and switch your distro on. With it off, the CLI in WSL has no socket and you get exactly this error.
The error strings, and what each one means
| Error text | Cause | Fix |
|---|---|---|
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? | Daemon stopped, or socket not created | sudo systemctl enable --now docker; read the journal if it fails |
error during connect: ... dial tcp 10.0.4.12:2375: connect: connection refused | DOCKER_HOST points at a dead remote | unset DOCKER_HOST, remove it from your profile |
unable to configure the Docker daemon with file /etc/docker/daemon.json | Bad JSON, or a directive set both in the file and as a flag | Fix the JSON, or the systemd drop-in above |
permission denied while trying to connect to the Docker daemon socket | Daemon is up, your user cannot open the socket | Group membership; see below |
Failed to connect to bus: No such file or directory | systemctl --user with no user session (after sudo su) | Log in as the user directly, for example over SSH |
The permission row is a lookalike: the daemon is fine, your user just lacks access. The tell is that sudo docker ps works and plain docker ps does not. That one has its own walkthrough in fixing Docker permission denied, and the wider set of Docker daemon errors lives in our troubleshooting guide.
Where this breaks
This checklist assumes a single local engine you control. On a managed CI runner, the daemon may be a sidecar (Docker-in-Docker) that starts after your step, so the fix is ordering or a wait loop, not systemd. Podman and Colima expose their own socket paths and contexts, so systemctl status docker is the wrong question there. And on a remote DOCKER_HOST over SSH, the daemon you need to inspect lives on the other machine.
Questions people ask
How do I check if the Docker daemon is running?
Run docker info. If the output includes a Server: section with a version, the client reached a daemon; if it ends with "Cannot connect to the Docker daemon", it did not. On Linux with systemd, systemctl status docker shows whether the service is active, and ps aux | grep dockerd confirms the process. For rootless installs, use systemctl --user status docker instead.
Why does Docker say cannot connect after a reboot?
Usually the service was started once but never enabled, so it does not start at boot. Run sudo systemctl enable --now docker to start it now and on every boot. On Docker Desktop, the app itself has to be running, so either open it or turn on its start-at-login setting. A stale DOCKER_HOST in a shell profile can produce the same symptom.
How do I fix "Cannot connect to the Docker daemon" in WSL2?
If you use Docker Desktop on Windows, open Settings, Resources, WSL Integration and enable your distro, then restart the WSL shell. The CLI inside WSL only gets a socket when that integration is on. If you installed the native engine inside the distro instead, start it there, and make sure DOCKER_HOST is not left pointing at Desktop.
The call we'd make
Do not reinstall Docker. A working install is easy to wipe over this error when the real problem is a stale DOCKER_HOST in the shell. Check where the client points, confirm the daemon is up, and read the journal if it will not start. Treat it as a routing question, not a broken-engine question, and you will close it in two minutes.
Sources
Cite this article
Kiril Urbonas (2026). Fix "Cannot Connect to the Docker Daemon". DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/fix-cannot-connect-docker-daemon
[Fix "Cannot Connect to the Docker Daemon"](https://www.devopsness.com/blog/fix-cannot-connect-docker-daemon) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from DevOps
Explore more articles in this category
kaniko CVE-2026-105769: Lookalike ACR Hosts Get Your Azure Token. Rebuild on v1.25.20
A FROM line pointing at a host like x.azurecr.io.attacker.com is enough to make kaniko hand the build's Entra ID token to that host. Which kaniko forks and images are affected, how to find Azure identities in your build pods, and what to rotate.
Sign Container Images With Cosign: Keyless GitHub Actions Workflow, SBOM and In-Cluster Checks
One workflow that builds, signs keylessly with GitHub OIDC, attaches an SBOM and SLSA provenance, plus the Kyverno policy that refuses anything unsigned. Copy it, change three names, ship it.
GitLab CVE-2026-110264: A Second CVSS 10 RCE in Nine Days. Patch to 19.5.1
An unauthenticated regex-compiler RCE reaching back to GitLab 7.0, no workaround, and backports on older branches that fix only the critical bug. The exact version per branch and the commands to get there.
You might have missed
Evergreen posts worth revisiting.