How to Fix 'Cannot connect to the Docker daemon' Error
Error Message
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Quick Fix
sudo systemctl start docker
Why Does This Happen?
The Docker CLI communicates with the background Docker daemon (dockerd) via a Unix socket. The error appears when the daemon is stopped, Docker Desktop is not open, or your user lacks permission to access /var/run/docker.sock.
Step-by-Step Solution
1
Fix on Linux (Ubuntu, Debian, Fedora)
Start the Docker service and enable it to start on boot:
Terminal / Code
sudo systemctl start docker
sudo systemctl enable docker
docker ps
If it shows active (running), you are good to go.
2
Fix permissions (remove sudo requirement)
Add your user to the docker group:
Terminal / Code
sudo usermod -aG docker $USER
newgrp docker
docker ps
You may need to log out and log back in for group changes to apply.
3
Fix on macOS & Windows (Docker Desktop)
Docker on macOS/Windows runs inside Docker Desktop — open the application first:
Terminal / Code
# 1. Open Docker Desktop from Applications / Start Menu
# 2. Wait for the whale icon to turn solid (not animated)
# 3. Then test:
docker version
If Docker Desktop is stuck, click the whale icon > Restart Docker.
Common Mistakes to Avoid
Running Docker CLI in terminal before opening the Docker Desktop app on macOS.
Frequently Asked Questions
How do I fix this in WSL2?
Open Docker Desktop > Settings > General > check 'Use WSL 2 based engine'. Then in Resources > WSL Integration, enable your Linux distro.
Learn to Write Code That Doesn't Break
DoxaTech Hub's 10-month programme teaches you Git internals, Linux systems, C, Python, SQL, Docker, and React from first principles — so you spend less time fixing errors and more time shipping.
Start Learning →