🔧 Error Fixes
· 1 min read

Docker: Permission Denied While Trying to Connect — How to Fix It


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

Your user doesn’t have permission to talk to the Docker daemon. By default, only root and users in the docker group can use Docker.

Fix 1: Add your user to the docker group

sudo usermod -aG docker $USER

Then log out and log back in (or restart your terminal). Verify:

groups
# Should include "docker"

docker ps
# Should work without sudo

Fix 2: Quick fix with newgrp (no logout needed)

sudo usermod -aG docker $USER
newgrp docker
docker ps  # Works now

newgrp activates the group in your current session without logging out.

Fix 3: Start the Docker daemon

If Docker isn’t running at all:

# Check if Docker is running
sudo systemctl status docker

# Start it
sudo systemctl start docker

# Enable it to start on boot
sudo systemctl enable docker

Fix 4: Fix socket permissions (temporary)

sudo chmod 666 /var/run/docker.sock

⚠️ This is a quick hack, not a permanent fix. The permissions reset on reboot. Use Fix 1 instead.

Fix 5: On macOS — start Docker Desktop

On macOS, Docker runs through Docker Desktop. If you get permission errors:

  1. Open Docker Desktop
  2. Wait for it to fully start (whale icon stops animating)
  3. Try your command again

If Docker Desktop isn’t installed, install it from docker.com.

📘