Error Knowledge Base Docker cannot_connect_to_daemon

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

The Docker CLI cannot reach the Docker daemon, usually because the engine is stopped, the context is wrong, or the socket is unavailable.

Fix it fast

Most likely: Docker itself is not reachable from this shell: the daemon is stopped, Docker Desktop is still starting, or the CLI is pointed at the wrong context or DOCKER_HOST.

1. Confirm this is your error
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
2. Check the cause
docker version
docker context show
docker context ls
echo "$DOCKER_HOST"
3. Apply the safe fix
# Docker Desktop: start Docker Desktop and wait until it reports that Docker is running.

# Linux systemd hosts:
sudo systemctl start docker

# If the CLI is pointed at the wrong daemon, return to the default local context.
docker context use default
unset DOCKER_HOST
4. Verify it works
docker info
docker version
Don't use unsafe shortcuts
  • Do not troubleshoot image names, tags, or registry credentials until docker info can reach the daemon.
  • Do not use sudo docker ... as the long-term fix for a normal user setup, fix group or socket access instead.
  • Do not leave a stale DOCKER_HOST value in your shell or CI job if you no longer use that remote daemon.

What Docker Could Not Reach

Read this as a precise clue about which part of the workflow broke first. Once you know the failing layer, the fix path gets much shorter.

Restore Docker daemon access

Check daemon connectivity:docker version (server section should appear).

If Docker is not running, start/restart it (Docker Desktop, or sudo systemctl start docker).

Check active context:docker context ls and docker context show

If using a remote daemon, validate DOCKER_HOST and TLS settings.

Check the daemon endpoint and socket

On Linux, check socket permissions with ls -la /var/run/docker.sock, and confirm your user groups include docker (then re-login): groups.

Why It Happens

Usually this comes down to the Docker daemon is not running, you are pointing at the wrong Docker context/host (DOCKER_HOST / context mismatch), or you do not have permission to access the Docker socket.

Prove the Failing Environment Can Reach It

Run docker info and confirm it returns daemon details, and retry the original Docker command.

How Docker reaches the daemon

The Docker CLI is a client that talks to the Docker daemon via a Unix socket or TCP. When the daemon is down, unreachable, or blocked by permissions, the CLI fails immediately.

Prevent It From Coming Back

To prevent this, keep Docker Desktop / Docker Engine updated on build machines, avoid hardcoding DOCKER_HOST unless you truly need remote contexts, and monitor daemon health on CI runners.

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list