The docker command is only a client. It talks to the Docker daemon (dockerd) over a socket, normally /var/run/docker.sock. This error means the client could not reach the daemon, for one of four reasons: the daemon is not running, you lack permission on the socket, the client is pointed at the wrong place, or the socket is in an unusual location.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
A related message points at permissions rather than a stopped daemon:
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: ... connect: permission denied
Check in this order
- Is the daemon running?
systemctl status docker - Does the socket exist?
ls -l /var/run/docker.sock - Is the message "permission denied"? Then it is group membership, not a stopped daemon.
- Is
DOCKER_HOSTor a Docker context redirecting the client?echo $DOCKER_HOSTanddocker context ls - Are you in WSL, a container, or a VM? Each has its own rules.
1. Start the daemon (Linux)
sudo systemctl status docker
sudo systemctl start docker
sudo systemctl enable docker # start at boot
If it fails to start, read why:
sudo journalctl -u docker --no-pager -n 50
sudo dockerd --debug # run in foreground to see errors
Common reasons it will not start are a syntax error in /etc/docker/daemon.json (validate with python3 -m json.tool /etc/docker/daemon.json), a full disk (see Docker no space left on device), or a conflicting setting between daemon.json and flags in the systemd unit, such as a duplicated hosts entry.
On Docker Desktop for macOS or Windows there is no systemd service. Open Docker Desktop and wait until it reports that the engine is running; the client fails exactly like this while the app is still starting.
2. Fix socket permissions
The socket is owned by root:docker with mode 660. A user outside the docker group gets "permission denied". Add yourself, then start a new login session:
sudo usermod -aG docker $USER
newgrp docker # or log out and back in
docker ps
If you do not want to change groups, sudo docker ps works as a one-off. Do not chmod 666 the socket; it grants everyone root-equivalent access.
3. Check where the client is pointed
Environment variables and contexts override the default socket:
echo "$DOCKER_HOST"
docker context ls
docker context use default
unset DOCKER_HOST
A leftover DOCKER_HOST=tcp://... from an old VM, or a context for Colima, Minikube or a remote machine, produces this error when the target is down. docker info shows which endpoint is in use.
4. Special environments
- WSL2: Either enable WSL integration for your distro in Docker Desktop's settings, or install Docker Engine inside the distro and make sure systemd is enabled (
/etc/wsl.confwith[boot] systemd=true), then runsudo systemctl start docker. - Inside a container: Docker is not available unless you mount the host socket (
-v /var/run/docker.sock:/var/run/docker.sock) and install a client. Mounting the socket gives that container control of the host, so use it deliberately. - CI runners: Docker-in-Docker setups need the service container started and
DOCKER_HOSTset to its address, oftentcp://docker:2375or2376with TLS. Check the runner's docs for the exact values. - Snap installs: the socket can live elsewhere, and snap confinement can restrict paths. Check
snap services docker. - Rootless Docker: the socket is per-user, at
$XDG_RUNTIME_DIR/docker.sock, and the client needsDOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock.
Remote daemons over TCP
If you connect to a remote daemon with DOCKER_HOST=tcp://host:2376, the error means that host and port did not answer. Test the connection with the पोर्ट चेकर against the daemon's IP and port, and confirm firewalls allow it.
Verify
docker version # shows Client and Server sections
docker run --rm hello-world
If only the Client section prints, the daemon is still unreachable. If your containers also host a public site, confirm it recovered with the वेबसाइट हेल्थ चेक and the Docker website down checklist.
अगले कदम
- Walk the Docker website down checklist.
- Free the disk if the daemon will not start: Docker no space left on device.
- Test a remote daemon port with the पोर्ट चेकर.
- Monitor the sites your containers serve with an uptime monitor.
सामान्य प्रश्न
Why does sudo docker ps work but docker ps does not?
Your user is not in the docker group, so the socket denies you. Add the user with usermod -aG docker, then start a fresh login session.
I added myself to the docker group but it still fails?
Group changes apply to new sessions. Log out and back in, or run newgrp docker, and confirm with id.
The daemon says it is running but the client cannot connect?
Check DOCKER_HOST and docker context ls. The client may be targeting a different endpoint than the local daemon.
Is it safe to expose port 2375?
No. It is unauthenticated and gives full control of the machine. Use TLS on 2376 or an SSH connection instead.
Get notified when this fix updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.