Knowledge

Fix: Cannot connect to the Docker daemon at unix:///var/run/docker.sock

#Development

This error means your Docker client could not reach the Docker daemon. Either the daemon is not running, or your user does not have permission to talk to its socket.

Published by Mark van Eijk on June 23, 2026 · 1 minute read

  1. About the error
  2. Why do I see this error
  3. Solution: start the daemon
  4. Solution: fix the permission denied case
  5. Still failing? Check the context

About the error

Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?

The docker command you type is just a client. It sends instructions to a background service, the Docker daemon (dockerd), over a Unix socket at /var/run/docker.sock. This error appears when the client cannot reach that daemon.

Why do I see this error

  • The Docker daemon is not running.
  • Your user is not allowed to access the socket (a permissions issue).
  • Your client is pointed at the wrong Docker context or a stale DOCKER_HOST.

Solution: start the daemon

On macOS or Windows, the daemon runs inside Docker Desktop. Make sure Docker Desktop is open and has finished starting (the whale icon stops animating).

On Linux, start and enable the service so it also comes back after a reboot:

sudo systemctl start docker
sudo systemctl enable docker

Check that it is actually running:

sudo systemctl status docker

Solution: fix the permission denied case

If the daemon is running but you still see the error (often phrased as permission denied while trying to connect), your user is not in the docker group. Add it:

sudo usermod -aG docker $USER

Group membership only applies to new sessions, so log out and back in, or start a fresh shell with:

newgrp docker

Then verify:

docker run hello-world

Still failing? Check the context

If Docker is running and you have permission, your client may be pointed somewhere else. List your contexts and confirm the active one:

docker context ls

Also check for a leftover environment variable overriding the socket:

echo $DOCKER_HOST

If DOCKER_HOST is set to something unexpected, unset it and try again. Once the daemon is reachable, you can clean up unused Docker data with prune or run a command in a container with docker exec.

Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

Related articles

Install PHP memcached extension on macOS

This error means your Docker client could not reach the Docker daemon. Either the daemon is not running, or your user does not have permission to talk to its socket.

Read more →

How to delete a local (and remote) Git branch

This error means your Docker client could not reach the Docker daemon. Either the daemon is not running, or your user does not have permission to talk to its socket.

Read more →