GrepBoard/Manuals
605 manuals ·

Fix Docker permission denied connecting to the daemon socket

·Tested on Ubuntu 24.04 (Docker) · docker CLI 29.1.3 · 24.0.7 · 2026-10·Test scope ↓·6 steps

Docker "permission denied ... daemon socket" means your user is not in the docker group. Add it with usermod -aG, log in again, and never chmod 666 the socket.

output
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

You ran docker without sudo, and your user is not in the docker group, so it cannot open the daemon socket. Add the user to docker and log in again. The daemon itself is fine; restarting it will not help.

The docker CLI 29 series prints a shorter version of the same error. Search for both.

output
permission denied while trying to connect to the docker API at unix:///var/run/docker.sock

[1] Compare the socket's group with your own groups. A socket owned by root docker with srw-rw---- can only be opened by members of docker.

console
$ iduid=1001(alice) gid=1002(alice) groups=1002(alice)$ getent group dockerdocker:x:1001:$ ls -l /var/run/docker.socksrw-rw---- 1 root docker 0 Oct 27 00:54 /var/run/docker.sock

groups= has no docker, and the getent line ends empty. That is the cause. If the socket's group is not docker, or the path is different, go to step 5.

[2] Add the user to the docker group. These are the commands from the official post-install guide. If the package already created the group, groupadd only reports that it exists and changes nothing.

console
$ sudo groupadd docker$ sudo usermod -aG docker $USER$ getent group dockerdocker:x:1001:alice

Keep the a in -aG. Without it, usermod -G replaces all other supplementary groups, including sudo.

[3] Log out and log back in. Group membership is set at login, so a shell that was already open keeps failing even right after usermod. After logging in again, check that id lists docker.

console
$ iduid=1001(alice) gid=1002(alice) groups=1002(alice),1001(docker)$ docker ps

To use it in the current session, newgrp docker opens a new shell with the group (the alternative given in the docs). Over SSH, disconnect and reconnect.

[4] If the group is right but you also see WARNING: Error loading config file, ~/.docker is owned by root. This happens when an earlier sudo docker … (a login, for example) created the folder as root.

output
WARNING: Error loading config file: open /home/alice/.docker/config.json: permission denied

Give it back to the user, as the docs show:

console
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R$ sudo chmod g+rwx "$HOME/.docker" -R

Deleting the folder also clears the warning, but you lose settings such as docker login credentials.

[5] If the message is not permission denied, it is a different problem. When the daemon is down or the socket path is wrong, you get:

CLIMessage when the daemon cannot be reached
29.1.3failed to connect to the docker API at unix:///var/run/docker.sock; check if the path is correct and if the daemon is running: dial unix /var/run/docker.sock: connect: no such file or directory
24.0.7Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Check the daemon with systemctl status docker, and check which socket the CLI is using with echo $DOCKER_HOST and docker context ls. A rootless daemon listens on unix:///run/user/<UID>/docker.sock, not /var/run/docker.sock, and needs no docker group.

[6] Do not change the socket mode yourself. sudo chmod 666 /var/run/docker.sock shows up in many answers; it gives every account on the host root-level access. If you already did it, put it back with sudo chmod 660 /var/run/docker.sock and go to step 2. For users you do not want in the group, rootless mode (a daemon owned by that user) is the official alternative.

For errors after you reach the daemon, see Docker port is already allocated and Docker exec format error.

#docker#docker-group#permission-denied#docker-sock