"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.
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 directorydocker 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.
- docker (the client)your commandtalks to
- Socketunix:///var/run/docker.socknobody answers(fails)
- dockerdnot running, or elsewhere(breaks here)
TL;DR
On a Linux server:
sudo systemctl status dockersudo systemctl enable --now dockersudo journalctl -u docker -n 50 --no-pager # if it won't startOn a Mac or Windows, start Docker Desktop and wait until it’s ready.
1. Is the service running?
If it’s inactive, start it, and make it start at boot too:
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:
systemctl status docker.socket2. It won’t start: read why
failed needs the log:
sudo journalctl -u docker -n 50 --no-pagerHere’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:
sudo systemctl stop docker docker.socketsudo dockerd --debugPress 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:
echo "$DOCKER_HOST"docker context lsDOCKER_HOST overrides everything. A leftover in your shell profile or a .env file sends the client to a server that isn’t there:
unset DOCKER_HOSTContexts do the same thing, more quietly. The current one has a *:
NAME DESCRIPTION DOCKER ENDPOINTdefault Current DOCKER_HOST based configuration unix:///var/run/docker.sockdesktop-linux * Docker Desktop unix:///home/alex/.docker/desktop/docker.sockWith 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:
docker context use default4. 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:
open -a Docker5. 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=trueThen, 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:
systemctl --user status dockersystemctl --user start dockerexport DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sockMake 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:dindservice. The CI/CD Pipeline Generator writes this, including its TLS settings, and on your own runner it needsprivileged = true. - GitHub Actions: the
ubuntu-latestrunner already has Docker, so you only need to take care when a job runs inside acontainer:. - 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.
Found this useful? Share it.
Found a mistake? Let us know at contact@ohsudo.com.