Error Encyclopedia

Cannot Connect to Docker Daemon

Fix 'Cannot connect to the Docker daemon' error. Learn how to start Docker Desktop, check daemon status, and resolve permission issues.

What Does This Error Mean?

The 'Cannot connect to the Docker daemon' error means the Docker client (CLI) cannot communicate with the Docker daemon (dockerd). This usually means the daemon is not running, the Docker socket is not accessible, or the DOCKER_HOST environment variable points to the wrong address.

Common Causes

1

Docker Desktop or dockerd service is not running

2

User does not have permission to access the Docker socket (Linux)

3

DOCKER_HOST environment variable is set incorrectly

4

Docker daemon crashed or was killed

5

WSL2 integration issues on Windows with Docker Desktop

6

Docker socket file (/var/run/docker.sock) does not exist or has wrong permissions

How to Fix It

Start Docker Desktop / daemon

Ensure the Docker service is running on your system.

# Windows: Start Docker Desktop from Start Menu
# Or restart from command line
"& \"C:\Program Files\Docker\Docker\Docker Desktop.exe\""

# macOS: Open Docker Desktop from Applications

# Linux: Start dockerd
sudo systemctl start docker
sudo systemctl enable docker  # Auto-start on boot

# Check daemon status
sudo systemctl status docker

Fix Docker socket permissions (Linux)

Add your user to the docker group to access the Docker socket.

# Add user to docker group
sudo usermod -aG docker $USER

# Restart session (log out and back in, or run:)
newgrp docker

# Verify access
docker ps

# If still failing, check socket permissions
ls -la /var/run/docker.sock
# Should be srw-rw---- docker:docker

Check DOCKER_HOST environment variable

Ensure DOCKER_HOST is not set incorrectly or unset it.

# Windows (PowerShell)
Get-ChildItem Env:DOCKER_HOST
Remove-Item Env:DOCKER_HOST -ErrorAction SilentlyContinue

# macOS / Linux
echo $DOCKER_HOST
unset DOCKER_HOST

# Default Docker daemon address
# Windows: npipe:////./pipe/docker_engine
# Linux: unix:///var/run/docker.sock
# macOS: unix:///var/run/docker.sock

Related Tools

Use these tools to debug and fix this error:

Related Errors

Other common errors in this category:

Frequently Asked Questions

Why does docker ps work with sudo but not without?

This means the Docker socket is only accessible by root. Add your user to the docker group with `sudo usermod -aG docker $USER` and restart your session. This is the most common Docker permission fix on Linux.

How do I restart Docker daemon on Windows?

Right-click the Docker Desktop icon in the system tray and select Restart. Or open PowerShell as Administrator and run `Restart-Service com.docker.service`. If Docker Desktop is not starting, check Windows features — ensure Windows Subsystem for Linux (WSL2) and Hyper-V are enabled.