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
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
dockergroup. - 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.
- Open a terminal.
- Create the
dockergroup if it does not already exist:sudo groupadd docker - Add your current user to the
dockergroup:sudo usermod -aG docker $USER - Apply the new group membership immediately to your active terminal:
newgrp docker - Verify that you can run Docker commands without
sudo:docker run hello-world
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.
- Check the status of the Docker service:
sudo systemctl status docker - If it is inactive, start the service:
sudo systemctl start docker - 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.
- Change the ownership of the Docker socket to the
dockergroup:sudo chown root:docker /var/run/docker.sock - Restart the Docker service:
sudo systemctl restart docker
Confirm the result
- Repeat the exact action that originally triggered the problem.
- Confirm the original error or symptom is gone and no new warning has appeared.
- If the guide changed a driver, service, package, or system setting, restart once and test again.
- 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
Did this solution resolve your issue?
Confirming if this works strengthens verification statistics on the registry.
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.
Discussion (0)
No comments yet. Share your experience or verify if this fixed your issue!
