About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When a docker command prints "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?", the client could not reach a daemon at the address it uses. Docker's troubleshooting page gives two reasons: the daemon "isn't running on your system", or the client is trying to reach a daemon on a different host that is unreachable. Check which before you start anything.
What the error means
The message comes from the Docker client library, and this wording is taken from its source code (the moby project, release tag v28.5.2), not from a documentation page. The source builds it in two forms. With an address it uses the format "Cannot connect to the Docker daemon at %s. Is the docker daemon running?", where %s is replaced by the address the client tried. When the address is empty it uses "Cannot connect to the Docker daemon. Is the docker daemon running on this host?". Docker's troubleshooting page prints an older wording, "Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?", and explains it the same way.
By default the client uses the Unix socket unix:///var/run/docker.sock on Linux. Three things can override that: the DOCKER_HOST environment variable ("Daemon socket to connect to"), the -H flag, and a Docker context. The contexts page says an active context is used "unless overridden with environment variables such as DOCKER_HOST and DOCKER_CONTEXT, or on the command-line with the --context and --host flags."
If the message says "permission denied" instead, the daemon is running and the problem is access to its socket. That is a different fault.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Daemon is stopped | systemctl is-active docker prints a state other than active |
docker info fails the same way |
| Daemon failed to start | The service is failed; the journal names an error | journalctl -xu docker.service |
daemon.json has an error or conflicts with a service flag |
A message such as "unable to configure the Docker daemon with file /etc/docker/daemon.json" | dockerd --validate --config-file=/etc/docker/daemon.json and the journal |
DOCKER_HOST set to another host |
The message names a tcp:// or ssh:// address |
The DOCKER_HOST check in step 3 below prints a value |
| Active context points elsewhere | The message names the context's address | docker context ls shows the asterisk on another context |
| Daemon stopped by the kernel for lack of memory | The daemon stopped without a service change | journalctl -k for out-of-memory messages |
Prove the cause before changing anything
All of these only read.
- Ask Docker, then the service. The troubleshooting page calls
docker infothe "operating-system independent way" to check, and listssudo systemctl is-active dockeras one of the operating system tools:
docker info
systemctl is-active docker
- Read the daemon log. The Docker logs page gives
journalctl -xu docker.servicefor Linux:
journalctl -xu docker.service
A good result is a recent start with no error. A bad result is an error line near the last start attempt.
- Check the client's target:
env | grep DOCKER_HOST
docker context ls
If the first command prints a value, the client is set to connect to a daemon on that host. If it prints nothing, the client uses the local host. The context list shows the active context with an asterisk.
- Validate the daemon configuration file without starting the daemon:
dockerd --validate --config-file=/etc/docker/daemon.json
The dockerd reference says this validates a configuration file "without starting the Docker daemon" and returns a non-zero exit code for an invalid file. Its example prints "configuration OK" for a valid file.
- Only if the daemon stopped by itself, read kernel messages. The Docker page says the daemon "might be stopped by the kernel OOM killer":
journalctl -k
Example (illustrative): On web01 an engineer adds "hosts": ["tcp://127.0.0.1:2376"] to /etc/docker/daemon.json and restarts Docker. Every docker command now prints the error. systemctl is-active docker does not print active. The journal shows the message the Docker page gives for this case (the page wraps it over three lines): "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 page explains that on Debian and Ubuntu with systemd, a -H flag is always used when starting dockerd, so a hosts entry in the file conflicts with it. Removing the hosts entry from the file fixes it.
Fix
The client points at the wrong place
If env | grep DOCKER_HOST printed a value you did not intend, the page's remedy is unset DOCKER_HOST, and it adds that you may need to edit files such as ~/.bashrc or ~/.profile if the variable is set there.
First print the current value and keep the output (the example below assumes it was DOCKER_HOST=tcp://198.51.100.20:2376):
env | grep DOCKER_HOST
Risk: the next command makes the client use the local daemon. If you meant to manage a remote host, later commands will act on this machine's containers instead.
Run this in the same shell:
unset DOCKER_HOST
To undo it: set the saved value again in that shell:
export DOCKER_HOST=tcp://198.51.100.20:2376
If the active context is the problem, the contexts page documents docker context use.
First list the contexts and keep the output (the example below assumes the asterisk was on docker-test):
docker context ls
Risk: the next command makes later docker commands go to the default context's daemon. Commands meant for the other context's host will run here.
docker context use default
To undo it: select the saved context again. DOCKER_CONTEXT set in the environment overrides this setting, so check it too.
docker context use docker-test
The daemon configuration is wrong
Use this section only if /etc/docker/daemon.json exists; check with ls -l /etc/docker/daemon.json. If the file does not exist, nothing in it can be the cause, so go to the next section. First save the current file:
cp -p /etc/docker/daemon.json /etc/docker/daemon.json.2026-11-22
Risk: the next edit changes the file the daemon reads at start. A mistake keeps Docker from starting and keeps every container on this host down.
Edit /etc/docker/daemon.json. If the journal names a duplicated option such as hosts, remove it from the file. Changing the service's own startup flags is a separate change that needs its own saved copy and back-out, and this section does not cover it. Then validate:
dockerd --validate --config-file=/etc/docker/daemon.json
A file that passes prints "configuration OK" and exits with 0. The daemon reports a conflict between the file and a service flag when it starts. This section does not start the daemon: continue with the next section, "The daemon is stopped", and read the journal after you start it.
To undo it: put the saved file back under its original name and validate it:
cp -p /etc/docker/daemon.json.2026-11-22 /etc/docker/daemon.json
dockerd --validate --config-file=/etc/docker/daemon.json
The daemon is stopped
First save the log so the failure is on record:
journalctl -u docker.service > docker-journal-2026-11-22.txt
Disruptive step: the next command starts the Docker daemon. Containers created with a restart policy such as always can start again as soon as the daemon is up, and the restart policies page says always restarts a container if it stops.
Start it, then check:
systemctl start docker
systemctl is-active docker
To undo it: stop the service, and read any warning it prints about units that can trigger the service again (the systemctl manual says such a warning names them). Running containers may stop with the daemon. The restart policies page says live restore lets you "keep your containers running during a Docker upgrade"; it does not describe what a plain stop does.
systemctl stop docker
If the daemon is not enabled at boot, the post-install page gives sudo systemctl enable docker.service; it also says Docker starts on boot by default on Debian and Ubuntu. First print the current setting and keep the output:
systemctl is-enabled docker
Disruptive step: the next command makes Docker start at every boot. The systemctl manual says enable does not start the unit now.
systemctl enable docker.service
To undo it: only if the noted output was disabled, run systemctl disable docker.service.
Confirm the fix
docker infoprints server details instead of the error.systemctl is-active dockerprints active.docker pslists the containers you expect.- After a reboot, the daemon is running without anyone starting it.
What to watch afterwards
- Validate
daemon.jsonwithdockerd --validatebefore every restart of Docker. - Check
env | grep DOCKER_HOSTafter changing shell profiles or deployment scripts. - Watch memory on the host. Docker's page warns that the kernel OOM killer can stop the daemon.
- Read
journalctl -xu docker.serviceafter any failed start before trying again.
Read next
Related articles you may want next.
- TroubleshootingDocker: permission denied while trying to connect to the Docker daemon socketDocker permission denied while trying to connect to the Docker daemon socket: check groups and socket, then choose sudo, the docker group or rootless mode.Read article
- Troubleshootingsystemd: "Job for nginx.service failed because the control process exited with error code" - find the real errorJob for nginx.service failed because the control process exited? Read systemctl status and journalctl, decode the exit status, test the config.Read article
- TroubleshootingDocker no space left on device: measure /var/lib/docker before you pruneDocker no space left on device: find what fills /var/lib/docker with docker system df, rotate logs, and prune images and cache without losing volumes.Read article
Risks and limits
- These commands have not been run or lab-tested.
- Docker Desktop, rootless mode and Windows hosts use different sockets and paths and are not covered.
- Stopping the daemon may stop the containers it runs; the cited page covers live restore only for upgrades.
- The conflict check between the file and service flags happens at start.
dockerd --validatechecks the file.
Sources
- Troubleshooting the Docker daemon — Docker Docs, updated 9 October 2026 (page metadata), accessed 22 November 2026
- dockerd reference — Docker Docs, updated 12 November 2026 (page metadata), accessed 22 November 2026
- Docker contexts — Docker Docs, updated 2 September 2024 (page metadata), accessed 22 November 2026
- docker CLI reference — Docker Docs, no date shown, accessed 22 November 2026
- Read the daemon logs — Docker Docs, updated 29 April 2026 (page metadata), accessed 22 November 2026
- Linux post-installation steps for Docker Engine — Docker Docs, updated 19 November 2026 (page metadata), accessed 22 November 2026
- Start containers automatically — Docker Docs, updated 16 August 2026 (page metadata), accessed 22 November 2026
- moby client errors.go, tag v28.5.2 — Moby project source code, no date shown, accessed 22 November 2026
- systemctl — systemd documentation, no date shown, accessed 22 November 2026
- journalctl — systemd documentation, no date shown, accessed 22 November 2026
- cp(1) — GNU coreutils 9.11 manual page, April 2026, accessed 22 November 2026
This article was originally published on .