Skip to content
Commitpedia
Log in Join & edit

Fix: permission denied while trying to connect to the Docker daemon socket

Every docker command fails with permission denied on /var/run/docker.sock. The daemon is fine; your user is not allowed to use its socket. Add the user to the docker group or use sudo.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of Fix: permission denied while trying to connect to the Docker daemon socket: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
2 min

On a fresh Docker Engine install on Linux, running any command as a normal user prints this:

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

Why it happens

The docker command is only a client. It talks to the Docker daemon over a Unix socket, /var/run/docker.sock, which is owned by root with group docker and mode 660. If your user is neither root nor in the docker group, the kernel refuses the connection before Docker is even involved. Check with:

ls -l /var/run/docker.sock
id
groups

Fix 1: Add your user to the docker group

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo usermod -aG docker $USER
newgrp docker
docker ps

Group changes apply to new login sessions. newgrp docker starts a subshell with the new group right away; otherwise log out and back in, or on a server close the SSH session and reconnect. If the group does not exist (some distributions do not create it), create it first with sudo groupadd docker and restart the daemon with sudo systemctl restart docker so the socket picks up the group.

Careful: a member of the docker group can start a container that mounts the host’s root file system, which is equivalent to root access on the machine. Only add accounts you would trust with sudo.

Fix 2: Use sudo

If you would rather not grant that level of access, simply prefix commands with sudo. This is the normal choice on shared servers:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo docker ps

Fix 3: Rootless Docker

Rootless mode runs the daemon itself as your user, so no group or sudo is needed and a container escape does not give root. It has some limitations (for example, binding ports below 1024 needs extra configuration). Install it with the docker-ce-rootless-extras package and dockerd-rootless-setuptool.sh install; see the documentation link below.

Related messages

  • Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? is a different problem: the daemon is not running. Start it with sudo systemctl start docker on Linux, or open Docker Desktop on macOS and Windows.
  • Got permission denied on the socket after a reboot usually means you fixed it with newgrp only in one shell and never logged out; a fresh login solves it.
  • Inside WSL on Windows, the socket belongs to Docker Desktop. Enable the WSL integration for your distribution in Docker Desktop settings instead of installing a second daemon.

Official documentation

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

  • 0055 Docker basics: images, containers and the commands you need An image is a read-only package of an app and its dependencies, and a container is a running instance of it. Learn… Beginner · Explains an idea · Linux, macOS, Windows Article Docker basics 15 Oct 2026
  • 0056 Docker Compose: run a small web app with a database Docker Compose describes several containers, their ports, volumes and environment in one compose.yaml file, then starts them all with docker compose up. Intermediate · Step by step · Linux, macOS, Windows Article Docker basics · Docker Compose 15 Oct 2026
  • 0250 Containerize a Node.js app and run it with PostgreSQL using Docker Compose Package a small Node.js web app in a multi-stage Docker image, then run it next to PostgreSQL with Docker Compose, named volumes,… Intermediate · Guided project · Linux, macOS, Windows Article Docker basics · Docker Compose · PostgreSQL 15 Oct 2026
  • 0268 What is a container? A container is a lightweight box that packs a program with everything it needs so it runs the same on any computer. Beginner · Explains an idea · Any system Article Docker basics 15 Oct 2026
  • 0327 Docker images, containers and volumes explained An image is a read-only template, a container is a running copy of it with a thin writable layer, and a volume… Beginner · Explains an idea · Linux, macOS, Windows Article Docker basics 15 Oct 2026
  • 0328 Install Docker Engine on Ubuntu and Debian Set up Docker's official apt repository, install Docker Engine with the Compose and Buildx plugins, run hello-world and let your user run… Beginner · Step by step · Linux Article Docker basics · Packages & updates 15 Oct 2026

Repos in the wild

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +2,694 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?