How to fix Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? in Docker

DockerBEGINNERMEDIUMUpdated Dec 1, 2025· 249 views

This error occurs when the Docker client cannot communicate with the Docker daemon. The fix typically involves starting the Docker service or fixing permission issues.

Quick fix

Fixes Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

sudo systemctl status docker
  1. Check if Docker daemon is running
  2. Start the Docker service
  3. Enable Docker to start on boot
  4. Fix permission issues (Linux)
docker — error
sudo systemctl status docker
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

What this error means

The "Cannot connect to the Docker daemon at unix:///var/run/docker.sock" error indicates that the Docker CLI (command-line interface) is unable to establish a connection with the Docker daemon (dockerd). The Docker daemon is a background service that manages Docker containers, images, networks, and volumes. The Docker client communicates with the daemon through a Unix socket located at /var/run/docker.sock. When this socket is unavailable—either because the daemon isn't running, the socket file doesn't exist, or your user lacks permission to access it—you'll encounter this error. This is one of the most common Docker errors, especially on Linux systems after installation or system reboots. On Windows and macOS, it typically means Docker Desktop isn't running.

Typical symptoms

  • Any docker command (docker ps, docker run, docker build) fails with the same error message
  • Docker commands work with sudo but fail without it
  • Docker Desktop application is not running (Windows/macOS)
  • The Docker service shows as inactive or failed in systemctl status
  • CI/CD pipelines fail at the first Docker command
  • The file /var/run/docker.sock does not exist

Common causes

  1. Docker daemon (service) is not running
  2. Docker Desktop is not started (Windows/macOS)
  3. User lacks permission to access the Docker socket
  4. Docker was not configured to start on boot
  5. WSL integration is disabled in Docker Desktop settings
  6. DOCKER_HOST environment variable is set incorrectly
  7. Docker installation is incomplete or corrupted
  8. Systemd or containerd service dependency failed
  9. The docker.socket systemd unit needs to be restarted

How to fix "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"

1Check if Docker daemon is running

First, verify the status of the Docker service:

bash
sudo systemctl status docker

If the output shows "inactive (dead)" or "failed", the daemon is not running. On older systems without systemd:

bash
sudo service docker status
2Start the Docker service

If the Docker daemon is not running, start it with:

bash
sudo systemctl start docker

Or on older init systems:

bash
sudo service docker start

Verify it's running:

bash
docker info
3Enable Docker to start on boot

To prevent this issue after reboots, enable the Docker service to start automatically:

bash
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
4Fix permission issues (Linux)

If Docker works with sudo but not without, add your user to the docker group:

bash
sudo usermod -aG docker $USER

Important: You must log out and log back in for the group changes to take effect. Alternatively, run:

bash
newgrp docker

Verify your group membership:

bash
groups
5Start Docker Desktop (Windows/macOS)

On Windows or macOS, the Docker daemon runs inside Docker Desktop. Start the Docker Desktop application:

- Windows: Search for "Docker Desktop" in the Start menu and launch it
- macOS: Open Docker from Applications or use Spotlight (Cmd + Space, type "Docker")

Wait for the Docker icon in the system tray/menu bar to show "Docker Desktop is running".

6Fix WSL integration (Windows with WSL 2)

If using Docker Desktop with WSL 2 and the error appears in your WSL terminal:

1. Open Docker Desktop settings (click the gear icon)
2. Go to Resources > WSL Integration
3. Ensure "Enable integration with my default WSL distro" is checked
4. Enable integration for your specific distro (e.g., Ubuntu)
5. Click Apply & Restart

Also check Settings > General > "Use the WSL 2 based engine" is enabled.

7Check DOCKER_HOST environment variable

An incorrectly set DOCKER_HOST variable can cause connection issues:

bash
echo $DOCKER_HOST

If it returns a value (and you're not intentionally using a remote Docker host), unset it:

bash
unset DOCKER_HOST

To make this permanent, check and remove any DOCKER_HOST lines from ~/.bashrc, ~/.zshrc, or ~/.profile.

8Restart the Docker socket (Linux)

Sometimes the Docker socket needs to be restarted separately:

bash
sudo systemctl restart docker.socket
sudo systemctl restart docker

This has resolved issues for users on Ubuntu 22.04 and later.

9Reinstall Docker (last resort)

If none of the above solutions work, consider reinstalling Docker:

bash
# Remove existing installation
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Remove leftover files
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

# Reinstall following official docs
# https://docs.docker.com/engine/install/

Warning: This will remove all containers, images, and volumes. Back up important data first.

Advanced notes

### Rootless Docker

If you're running rootless Docker (Docker without root privileges), the socket path is different. Check if your socket exists at:

bash
ls -la $XDG_RUNTIME_DIR/docker.sock
# or
ls -la ~/.docker/run/docker.sock

You may need to set DOCKER_HOST accordingly:

bash
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock

### Docker Context

Docker supports multiple contexts for connecting to different Docker daemons. Check your current context:

bash
docker context ls
docker context use default

### Container/VM Issues

On Docker Desktop for Mac/Windows, the daemon runs inside a lightweight VM. If this VM is in a bad state:

1. Quit Docker Desktop completely
2. On Mac: rm -rf ~/Library/Containers/com.docker.docker
3. Restart Docker Desktop

### CI/CD Pipelines

In GitLab CI or similar environments using Docker-in-Docker (DinD), you may need to configure:

yaml
variables:
  DOCKER_HOST: tcp://docker:2375
  DOCKER_TLS_CERTDIR: ""

Frequently asked questions

What does "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is" mean?
sock" error indicates that the Docker CLI (command-line interface) is unable to establish a connection with the Docker daemon (dockerd). The Docker daemon is a background service that manages Docker containers, images, networks, and volumes. sock.
How do I fix "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is"?
This error occurs when the Docker client cannot communicate with the Docker daemon. The fix typically involves starting the Docker service or fixing permission issues.
What causes "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is"?
Docker daemon (service) is not running Docker Desktop is not started (Windows/macOS) User lacks permission to access the Docker socket
Is the "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading