Cannot connect to the Docker daemon (docker.sock / dockerd)

The Docker client talked to a socket or TCP endpoint and nobody answered like a daemon. Either dockerd is stopped, the socket path is wrong, or you are pointing at the wrong host.

How it shows up

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
error during connect: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json": dial unix /var/run/docker.sock: connect: no such file or directory

Compose, buildx, and language SDKs surface the same underlying dial failure.

Client vs daemon

  1. The client is the docker binary (or library) on your PATH.
  2. The daemon is dockerd (Linux) or Docker Desktop’s VM engine.
  3. They meet at a socket (/var/run/docker.sock) or a TCP/SSH context (DOCKER_HOST).

This error is “client could not speak to daemon”. It is not a failed docker build inside an already-connected session.

vs permission denied

MessageMeans
Cannot connect … Is the docker daemon running?Socket missing, connection refused, or wrong host — daemon likely down / wrong endpoint
permission denied while trying to connect to docker.sockSocket exists; your user is not in the docker group (or bad ACLs)
connection refused on DOCKER_HOST TCPNothing listening on that host:port

Frequent causes

Diagnose

# What does the client think it should dial?
docker context ls
echo "DOCKER_HOST=$DOCKER_HOST"
ls -l /var/run/docker.sock 2>/dev/null || echo "no sock"

# Linux service
systemctl status docker --no-pager
journalctl -u docker -n 50 --no-pager

# Can anything accept the sock?
curl -s --unix-socket /var/run/docker.sock http://localhost/_ping && echo

# Desktop / WSL: start Docker Desktop, then
wsl -e docker version

Fix checklist

  1. Start the engine — sudo systemctl start docker (and enable if you want it on boot), or launch Docker Desktop and wait until it says running.
  2. Clear a bad host — unset DOCKER_HOST; docker context use default.
  3. Rootless — start the user service (systemctl --user start docker) and export the rootless socket if documented for your install.
  4. Permissions — if the sock exists and you get permission denied, fix group membership (docker.sock permission denied), not “daemon running” alone.
  5. CI — ensure the DinD service is healthy and DOCKER_HOST matches (often tcp://docker:2375 or a mounted sock).
  6. Space / corruption — if dockerd exits immediately, free disk and inspect logs before retrying pulls.
# After the daemon is up
docker version          # Client + Server sections both populated
docker info | head
docker run --rm hello-world

Related

docker.sock permission denied · docker system prune / reclaim space · ENOSPC no space left · localhost refused to connect · Permission denied (publickey) · getaddrinfo ENOTFOUND

Questions

What does Cannot connect to the Docker daemon mean?

The Docker client could not reach dockerd at the configured socket or DOCKER_HOST. Usually the daemon is stopped or the endpoint is wrong.

Is the docker daemon running?

Check systemctl status docker, Docker Desktop status, or docker context. If /var/run/docker.sock is missing, the engine is not up (or uses another path).

How is this different from permission denied on docker.sock?

Permission denied means the socket exists but your user cannot access it. Cannot connect usually means nothing to connect to, or the wrong host.

What is DOCKER_HOST?

An environment variable telling the client where the daemon API is (unix socket or tcp/ssh URL). A stale value is a common cause of this error.

How do I fix it on Linux?

sudo systemctl start docker, unset bad DOCKER_HOST, use the default context, then docker version should show a Server section.

How do I fix it with Docker Desktop / WSL?

Start Docker Desktop, enable WSL integration for your distro, wait until it is idle/running, then retry docker version inside WSL.

Published .

Try it

Related guides

Newest guides