Fix 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?'
Start the Docker daemon, fix docker.sock permissions, or switch to the right Docker context on Linux, macOS, WSL2 and CI runners.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
# Linux: start the daemon sudo systemctl start docker # Permission denied on docker.sock? add yourself to the docker group sudo usermod -aG docker $USER && newgrp docker # macOS / Windows: open Docker Desktop (or: colima start) # Wrong context? switch to "default" docker context use default docker info
Root Cause & Mechanism Analysis
Why does this error occur?
The Docker CLI talks to the daemon (dockerd) through a Unix socket. The error appears when the daemon is stopped, Docker Desktop is not running, your user lacks permission on `/var/run/docker.sock`, or the CLI points to a stale Docker context.
Frequently Asked Questions
Is adding my user to the docker group safe?
Why does this happen inside WSL2?
Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?
Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.
Related Developer Error Solutions
Browse All 69 GuidesDocker: Bind for 0.0.0.0:Port Failed
Identify and terminate conflicting host processes or adjust Docker port mapping to resolve port bind collisions.
Docker: no space left on device
Clean dangling Docker build caches, unused volumes, and stopped containers to free disk space.
Docker: exec user process caused: exec format error
Resolve CPU architecture mismatches when building Docker images on Apple Silicon (M1/M2/M3/M4 `linux/arm64`) and deploying to x86_64 (`linux/amd64`) cloud servers.