Home › Docker

permission denied while trying to connect to the Docker daemon socket — how to fix

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

Quick fix: Run sudo usermod -aG docker $USER, then log out and back in (or run newgrp docker). Check with docker run hello-world.

What it means

The Docker CLI talks to the daemon through the socket /var/run/docker.sock, which is owned by root and the docker group. Your user is in neither.

Fix: add your user to the docker group

sudo groupadd docker          # usually exists already
sudo usermod -aG docker "$USER"

Group changes only apply to new login sessions. Either log out and back in, reboot, or start a shell with the new group:

newgrp docker
docker run hello-world

Check that it worked: groups should list docker.

Security note: members of the docker group effectively have root access to the machine (they can mount / into a container). Only add trusted users. For stricter setups, look at rootless Docker.

Still denied after re-login?

ls -l /var/run/docker.sock
sudo chown root:docker /var/run/docker.sock

Don't chmod 666 the socket: it gives every user on the machine root-level access.

Last updated 2026-10-27.