ProjectStack
docker

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

The current Linux user doesn't have permission to talk to the Docker daemon. By default the Docker socket is only accessible by root and members of the docker group. Running commands with sudo works, but the better fix is to add your user to the docker group.

Common causes

  • Your user account isn't in the docker group on Linux
  • You just added yourself to the docker group but haven't logged out and back in to pick up the new group membership
  • Running docker in a script where the executing user doesn't have group access
  • The docker group doesn't exist or the socket file permissions are wrong

How to fix it

  1. Add your user to the docker group: sudo usermod -aG docker $USER
  2. Log out and back in (or run: newgrp docker) for the group change to take effect
  3. Verify group membership: groups $USER — you should see docker listed
  4. As a quick workaround for a single command, prefix with sudo — but the group method is preferred for day-to-day use

Example

$ docker run hello-world Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: dial unix /var/run/docker.sock: connect: permission denied

Running docker on Linux as a non-root user who hasn't been added to the docker group

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.