CalcSnippets Search
Docker 3 min read

How to Fix Docker Permission Denied While Trying to Connect to the Docker Daemon Socket Without Randomly chmodding Everything

A practical guide to fixing Docker daemon permission errors on Linux and macOS by checking the real socket owner, Docker Desktop state, current user groups, and the difference between a Unix permission problem and a daemon that is not actually running.

Why this search keeps happening: the error looks like a permissions problem, but half the time it is actually Docker not running, the wrong context, or a user group change that never reached your current shell.

The classic message looks like this:

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

The lazy fix floating around the web is to chmod 666 /var/run/docker.sock. Do not do that unless you enjoy turning a local daemon into a security shortcut. The right fix starts with figuring out whether Docker is actually up and whether your user has the expected access path.

Step 1: confirm the daemon is running

On Linux:

systemctl status docker
sudo systemctl start docker

On macOS with Docker Desktop:

docker version
open -a Docker

If the client is installed but the server section is missing, that is not a socket permission issue yet. That is a daemon availability issue.

Step 2: inspect the socket and your current user

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

On most Linux setups, you want to see the socket owned by root:docker and your user included in the docker group.

If the docker group is missing from your current session, add it and reload the shell:

sudo usermod -aG docker "$USER"
newgrp docker

If you skip newgrp docker or a full logout/login, the group change may exist on disk but not in your active shell.

Step 3: test with and without sudo once

docker ps
sudo docker ps

This comparison is useful. If sudo docker ps works and plain docker ps fails, the daemon is probably fine and the issue is user access. If both fail, stop blaming Unix groups and look at the service itself.

Common causes by environment

Linux server or workstation

Most common causes:

  1. Docker service is not running
  2. your user is not in the docker group
  3. the group was added but the shell session was never refreshed

macOS with Docker Desktop

Most common causes:

  1. Docker Desktop is closed or stuck starting
  2. the CLI context points somewhere unexpected
  3. corporate device controls or virtualization permissions are blocking startup

Check the active context:

docker context ls
docker context use default

What not to do first

Avoid these “fixes” as your first move:

sudo chmod 666 /var/run/docker.sock
sudo chown $USER /var/run/docker.sock

They can hide the real problem and create a worse one. If the daemon restarts, those changes may disappear anyway.

A clean verification sequence

Run these after the fix:

docker ps
docker run --rm hello-world
docker info

If all three work, your socket access path is healthy.

Bottom line

Treat this error as a three-way diagnostic: daemon state, socket ownership, and active user session. Most fixes are short once you stop treating every Docker failure like a file permission puzzle.

Sources

Keep reading

Related guides