How to fix Docker can't connect to daemon?

Better Stack Team
Updated on April 7, 2023

The error message "Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?" typically occurs when the Docker client is unable to connect to the Docker daemon, either because it is not running or because it is not accessible to the client. Here are some steps you can take to fix this error:

Check if the Docker daemon is running by running the following command:

sudo systemctl status docker

If the Docker daemon is not running, you can start it using the following command:

sudo systemctl start docker

Check if the Docker daemon is accessible to the client by running the following command:

sudo docker info

If this command returns information about the Docker daemon, then the client is able to connect to the daemon and the error is likely caused by a permissions issue.

Check if the user running the Docker command is a member of the docker group. Only users in the docker group have permission to access the Docker daemon socket, which is located at /var/run/docker.sock. You can add a user to the docker group using the following command:

sudo usermod -aG docker <username>

Replace <username> with the username of the user you want to add to the docker group.

If the above steps do not resolve the issue, you can try restarting the Docker daemon and/or restarting the Docker service on the host system:

sudo systemctl restart docker
sudo service docker restart

Note that some Linux distributions may use a different command to manage services, such as systemctl instead of service. Check the documentation for your distribution to determine the correct command to use.

If none of these steps resolve the issue, it is possible that there is a more serious problem with the Docker installation or configuration. Check the Docker logs and consult the Docker documentation for more information.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →