Skip to content
FixingBook
Verifiedbeginnerest. 10 minutes

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

Fix the common permission issue when running Docker commands without sudo.

Confirmed working on: All Linux Distributions

Before you begin

Match the environmentUse this guide only for All Linux Distributions or a clearly compatible setup.
Protect recoveryBack up important data and save encryption or account recovery keys before changing system state.
Know when to stopMake one change at a time and stop if the result differs from what the guide describes.

Problem overview

When you try to run a Docker command like docker ps, you receive a permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock error.

Common causes

  • Your user account is not a member of the docker group.
  • The group changes have not been applied to your current terminal session.
  • The Docker daemon service is not running.

Solution 1: Add your user to the docker group

By default, the Docker daemon binds to a Unix socket owned by the root user. Members of the docker group also have access to this socket.

  1. Open a terminal.
  2. Create the docker group if it does not already exist:
    sudo groupadd docker
  3. Add your current user to the docker group:
    sudo usermod -aG docker $USER
  4. Apply the new group membership immediately to your active terminal:
    newgrp docker
  5. Verify that you can run Docker commands without sudo:
    docker run hello-world
Expert Tip

If you still get a permission denied error in your desktop environment (like a GUI IDE), log out and log back in completely.

Solution 2: Verify the Docker daemon is running

If fixing the permissions does not work, the Docker service itself might be stopped.

  1. Check the status of the Docker service:
    sudo systemctl status docker
  2. If it is inactive, start the service:
    sudo systemctl start docker
  3. Enable the service to start automatically on boot:
    sudo systemctl enable docker

Solution 3: Fix socket file ownership

If previous commands were run using sudo, the socket file might have incorrect permissions.

  1. Change the ownership of the Docker socket to the docker group:
    sudo chown root:docker /var/run/docker.sock
  2. Restart the Docker service:
    sudo systemctl restart docker

Confirm the result

  1. Repeat the exact action that originally triggered the problem.
  2. Confirm the original error or symptom is gone and no new warning has appeared.
  3. If the guide changed a driver, service, package, or system setting, restart once and test again.
  4. If the result is worse or unexpected, stop. Reverse only the last change using its documented restore option; if none is documented, use your backup or qualified support.

Questions about this fix

Is it safe to add my user to the docker group?

Adding a user to the docker group grants them privileges equivalent to the root user. Only do this for trusted users.

Do I have to reboot for the changes to apply?

No, you can use the newgrp command to apply the group changes immediately in your current terminal session.

Did this fix work for you?

Weighted Consensus Protocol

Consensus0%
Required100% (Weight 3)
Contributors0
Verified By YouNo
Your Weight--

Did this solution resolve your issue?

Confirming if this works strengthens verification statistics on the registry.

Sign In to VerifySign in required to verify

FixingTeam10,000 rep

Official Project Maintainers

The core engineering and moderation team behind FixingBook. We curate, verify, and maintain the standards of the troubleshooting ledger.

Spotted something outdated? Suggest an edit. Maintainers review submissions within 48 hours.
Share:XReddit

Discussion (0)

No comments yet. Share your experience or verify if this fixed your issue!

Join the Discussion