Cannot connect to the Docker daemon — daemon stopped or DOCKER_HOST wrong
Cannot connect to the Docker daemon at unix:///var/run/docker.sock — Is the docker daemon running?
Focused incident mode — strips away everything but this runbook.
Symptoms
- Cannot connect to the Docker daemon at unix:///var/run/docker.sock — Is the docker daemon running?
- docker ps fails with connection refused
- All docker commands fail with same daemon error
On systems with rootless Docker or Docker Desktop, the socket path may differ (e.g., /run/user/1000/docker.sock). Check DOCKER_HOST first.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Docker service status
systemctl status dockerDOCKER_HOST environment variable
env | grep DOCKER
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- systemctl status docker shows inactive (dead) or failed
- /var/run/docker.sock does not exist
Confirm before fixing
systemctl is-active dockerCheck if the service is active
Expected: active
Fix
sudo systemctl start docker && sudo systemctl enable dockerStart and enable the Docker daemon
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
systemctl status dockerCheck daemon service state
ls -la /var/run/docker.sockVerify socket exists and permissions
env | grep -i DOCKERCheck DOCKER_HOST override
sudo systemctl start docker && sudo systemctl enable dockerStart and persist the Docker daemon
groups <USER> | grep dockerConfirm user group membership
Prevention
- Enable the Docker daemon on boot: systemctl enable docker.
- Add deployment users to the docker group during provisioning.
- Use systemd socket activation for environments with strict socket permissions.
- Document the expected DOCKER_HOST and socket path in the runbook.
Related runbooks
Same stack, same failure family — worth a skim.
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.