Docker: Permission Denied on /var/run/docker.sock

Fresh Docker install, and every command says permission denied on the daemon socket. It's not a bug — your user just isn't in the docker group yet. Here's the fix and why it works.

BytExplorer 5 min read July 1, 2026

You install Docker, run docker ps, and get slapped with:

permission denied while trying to connect to the Docker daemon socket at
unix:///var/run/docker.sock

This isn't a broken install. Docker talks to its daemon over a Unix socket, /var/run/docker.sock, and that socket is owned by root and the docker group. Your regular user is in neither — so the kernel refuses the connection.

Why sudo "fixes" it (and why that's a trap)

sudo docker ps works because root can open the socket. But typing sudo before every command is a symptom, not a cure — and it means files created by containers end up owned by root. The real fix is to grant your user access properly.

Step 1: Add your user to the docker group

sudo usermod -aG docker $USER    # -a appends, -G names the group

This makes your user a member of the docker group, which owns the socket.

Step 2: Start a fresh session

Group membership is only read at login, so your current shell still doesn't know about it. Log out and back in, or force a new session:

newgrp docker      # or just close the terminal and reopen it
docker ps          # should work now, no sudo

If docker ps still fails right after usermod, you almost certainly skipped the re-login step — the old session is running with your old group list.

If it's still denied

Check the daemon is actually running and the socket exists:

systemctl status docker          # is the daemon up?
ls -l /var/run/docker.sock       # srw-rw---- root docker

The socket should be group-owned by docker. If the daemon is stopped, sudo systemctl start docker first.

The security footnote

Being in the docker group is effectively root-equivalent — a container can mount the host filesystem. That's fine on your own machine; on a shared server, treat docker group membership as handing out admin.

The checklist

  1. sudo usermod -aG docker $USER
  2. Log out and back in (or newgrp docker).
  3. docker ps with no sudo.
  4. Still stuck? Check systemctl status docker and the socket's group.
Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Troubleshooting