Skip to content
ohsudo, Home
Docker & Containers

"Cannot connect to the Docker daemon. Is the docker daemon running?": every cause

Fix "Cannot connect to the Docker daemon. Is the docker daemon running?": start the service, read why it failed, check DOCKER_HOST, contexts, Docker Desktop and WSL.

Beginner5 min readApplies to Docker Engine 20.10+ · Docker Desktop · Ubuntu · Debian · RHEL / Rocky / AlmaLinux · macOS · Windows with WSL 2

by OhSudo ··

Checked on real software: Docker · November 2026How we check

Not sure this is your cause?Find it step by step: Container won't start →

Part of a learning path:Docker: from first container to production

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

Recent Docker clients say the same thing in other words, when the socket file isn’t there:

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

docker is only a client. The work is done by a background service, the daemon (dockerd), and the client talks to it through a socket. So this message says the client couldn’t find anyone at the other end.

The address it names is your first clue. And the question in the message is usually the right one: most often the daemon just isn’t running.

  1. docker (the client)your command
  2. Socketunix:///var/run/docker.sock
  3. dockerdnot running, or elsewhere(breaks here)
docker is only a client. It talks to the daemon through a socket, and found nobody at the other end: usually the daemon isn't running.

TL;DR

On a Linux server:

Terminal window
sudo systemctl status docker
sudo systemctl enable --now docker
sudo journalctl -u docker -n 50 --no-pager # if it won't start

On a Mac or Windows, start Docker Desktop and wait until it’s ready.

1. Is the service running?

Terminal window
sudo systemctl status docker

If it’s inactive, start it, and make it start at boot too:

Terminal window
sudo systemctl enable --now docker
docker ps

A machine that’s just been installed, or rebooted with the service disabled, is the classic case. Docker is also socket-activated on many systems, through docker.socket, so check both:

Terminal window
systemctl status docker.socket

2. It won’t start: read why

failed needs the log:

Terminal window
sudo journalctl -u docker -n 50 --no-pager

Here’s what you may find in it:

In the log Means Fix
unable to configure the Docker daemon with file /etc/docker/daemon.json A typo in the JSON Check it: sudo python3 -m json.tool /etc/docker/daemon.json
the following directives are specified both as a flag and in the configuration file -H in the unit, and hosts in daemon.json Remove one of them
no space left on device A full disk See no space left on device
failed to start daemon: pid file found A stale PID file, or a daemon already running ps aux | grep dockerd, then remove /var/run/docker.pid if none runs
Start request repeated too quickly systemd gave up after repeated crashes Fix the cause above, then sudo systemctl reset-failed docker

To see the errors directly, run it in the foreground after stopping the service:

Terminal window
sudo systemctl stop docker docker.socket
sudo dockerd --debug

Press Ctrl+C when you’re done, then start the service again.

Job for service failed goes through reading a failing service in general.

3. Is the client looking in the wrong place?

The service can be running while the client calls some other address. Look at where it’s pointed:

Terminal window
echo "$DOCKER_HOST"
docker context ls

DOCKER_HOST overrides everything. A leftover in your shell profile or a .env file sends the client to a server that isn’t there:

Terminal window
unset DOCKER_HOST

Contexts do the same thing, more quietly. The current one has a *:

NAME DESCRIPTION DOCKER ENDPOINT
default Current DOCKER_HOST based configuration unix:///var/run/docker.sock
desktop-linux * Docker Desktop unix:///home/alex/.docker/desktop/docker.sock

With Docker Desktop installed on Linux, desktop-linux looks for the Desktop daemon, even if the Engine you want is running. Switch to the other one:

Terminal window
docker context use default

4. Docker Desktop

On macOS and Windows, the daemon lives inside Docker Desktop, so it has to be open, and finished starting: wait for the whale icon to stop moving. A newer Mac can also show a different path in the message:

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

That still just means it isn’t running. Set Desktop to Start Docker Desktop when you sign in under Settings → General, if you use it every day. On a Mac, you can start it from a terminal:

Terminal window
open -a Docker

5. WSL

There are two setups in Windows Subsystem for Linux, and they fail differently:

With Docker Desktop: open it, then Settings → Resources → WSL Integration, and enable your distribution.

With Docker Engine installed inside WSL: older setups have no systemd, so nothing starts the daemon. Turn systemd on in /etc/wsl.conf:

[boot]
systemd=true

Then, in Windows, restart it with wsl --shutdown. If WSL itself won’t start, see WSL error 0x80370102.

6. Rootless Docker

Rootless Docker runs as your user, with its socket in your runtime folder, so sudo systemctl won’t find it:

Terminal window
systemctl --user status docker
systemctl --user start docker
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock

Make it survive logging out with sudo loginctl enable-linger $USER.

7. In a container or CI job

A container doesn’t have a daemon of its own. The options are:

  • GitLab CI: add the docker:dind service. The CI/CD Pipeline Generator writes this, including its TLS settings, and on your own runner it needs privileged = true.
  • GitHub Actions: the ubuntu-latest runner already has Docker, so you only need to take care when a job runs inside a container:.
  • Mount the host’s socket: -v /var/run/docker.sock:/var/run/docker.sock. It works, but it hands that container full control of the host, so use it only for tools you trust.

Often you don’t need a daemon just to build an image. BuildKit and tools such as Kaniko or Buildah can build without one.

Warning

Don’t expose the daemon on TCP to fix this. -H tcp://0.0.0.0:2375 gives anyone who reaches that port root on your machine, and bots scan for it constantly. The Port Lookup has it marked as such. For remote control, use SSH: docker context create remote --docker "host=ssh://me@server01".

Shell, we have a problem!

Similar, but different: permission denied while trying to connect to the Docker daemon socket means the daemon is running and your user can’t use it: see that article. dial tcp …: connection refused points at a remote DOCKER_HOST. And docker: command not found means the client itself isn’t installed. For systemctl refusing to work at all in WSL or a container, see System has not been booted with systemd. If Docker runs and refuses a port, see port is already allocated. For the commands around this, see the Docker CLI Cheat Sheet. docker: 'compose' is not a docker command means the Compose plugin isn’t installed.

$ ./practice.sh

Practice this in the terminal

Open the Terminal Playground with this article’s scenario loaded. It is safe and runs in your browser.

Open the terminal →

Found this useful? Share it.

Found a mistake? Let us know at contact@ohsudo.com.

Tools

Try it yourself

Articles

Related articles