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

DockerBEGINNERMEDIUMUpdated Nov 30, 2025ยท 528 views

This error occurs when your user account doesn't have permission to access the Docker daemon. The Docker daemon runs as root, and by default, only root or users in the 'docker' group can connect to it.

Quick fix

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

  1. Check if the docker group exists
  2. Create the docker group (if needed)
  3. Add your user to the docker group
  4. Apply the new group membership
  5. Verify it works
docker โ€” error
# Got permission denied while trying to connect to the Docker daemon socket at uni
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

What this error means

The Docker CLI needs to communicate with the Docker daemon to run containers. This communication happens through a Unix socket at /var/run/docker.sock. By default, this socket is owned by root and the docker group. When you run Docker commands without sudo and your user isn't in the docker group, you get this permission denied error.

Typical symptoms

  • Running 'docker ps' or any docker command fails
  • Error message mentions /var/run/docker.sock
  • The word 'permission denied' appears in the error
  • Commands work with sudo but not without

Common causes

  1. Your user is not a member of the 'docker' group
  2. The docker group doesn't exist on your system
  3. Docker daemon is not running
  4. Socket permissions were changed manually
  5. You're in a restricted environment (like some CI systems)

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

1Check if the docker group exists

Run: getent group docker

If you see output like docker:x:999:, the group exists. If there's no output, you need to create it.

2Create the docker group (if needed)

Run: sudo groupadd docker

This creates the docker group. Skip this step if the group already exists.

3Add your user to the docker group

Run: sudo usermod -aG docker $USER

This adds your current user to the docker group. The -aG flags append the group without removing existing group memberships.

4Apply the new group membership

You need to log out and log back in for the group change to take effect. Alternatively, run: newgrp docker

This starts a new shell with the docker group active.

5Verify it works

Run: docker run hello-world

If successful, you'll see a message from Docker confirming your installation is working.

Advanced notes

Security consideration: Adding users to the docker group grants them root-equivalent privileges on the host. Any user who can run Docker commands can mount the host filesystem and access/modify any file. For production servers, consider using rootless Docker or Podman instead.

Alternative solutions:
- Use sudo for all Docker commands (secure but inconvenient)
- Configure rootless Docker: dockerd-rootless-setuptool.sh install
- Use Podman, which runs rootless by default

Frequently asked questions

What does "Got permission denied while trying to connect to the Docker daemon soc" mean?
The Docker CLI needs to communicate with the Docker daemon to run containers. sock. By default, this socket is owned by root and the docker group.
How do I fix "Got permission denied while trying to connect to the Docker daemon soc"?
This error occurs when your user account doesn't have permission to access the Docker daemon. The Docker daemon runs as root, and by default, only root or users in the 'docker' group can connect to it.
What causes "Got permission denied while trying to connect to the Docker daemon soc"?
Your user is not a member of the 'docker' group The docker group doesn't exist on your system Docker daemon is not running
Is the "Got permission denied while trying to connect to the Docker daemon soc" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading