DevFixes
HomeDockerContainers
DockerBeginnerHigh severity

Cannot connect to the Docker daemon

The Docker client cannot reach the Docker engine socket or service.

3-10 min Popularity 96/100 Verified 2026-07-21
Debug with AI

What does this error mean?

The `docker` command is installed, but the background engine that creates and manages containers is unavailable at the configured endpoint.

Why does this happen?

  • Docker Desktop or the Docker service is stopped.
  • The current user cannot access the Docker socket.
  • The Docker context points to an unavailable host.
  • WSL integration is disabled or unhealthy.
  • The `DOCKER_HOST` environment variable is incorrect.

AI explanation

Plain-English analysis

The Docker CLI is only a client. It sends requests to a separate engine process. This error means the client started correctly but could not open a connection to that engine.

Quick fix

Terminal
docker context show
docker info
Expected output: Docker prints server information instead of a connection error.

Step-by-step fix

1Start or restart the Docker engineOpen Docker Desktop, or restart the Docker service on Linux.84%
Command
sudo systemctl restart docker
2Reset the active Docker contextSwitch back to the local default context when the current endpoint is stale.52%
Command
docker context use default
3Fix Linux socket permissionsAdd your user to the docker group, then start a new login session.36%
Command
sudo usermod -aG docker $USER

Alternative solutions

Windows / macOS

Start Docker Desktop
docker info

Wait until Docker Desktop reports that the engine is running.

Linux

sudo systemctl enable --now docker
sudo systemctl status docker

Check the service logs if the engine exits immediately.

WSL

wsl --shutdown

Restart Docker Desktop after WSL has fully stopped.

Real example

Broken
shell
$ docker compose up
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Corrected
shell
$ sudo systemctl start docker
$ docker info
Server:
 Containers: 0
 Images: 12

Frequently asked questions

It confirms a permission issue, but the long-term fix is to configure socket access correctly instead of prefixing every command with sudo.

References