Cannot Connect to the Docker Daemon at unix:/var/run/docker.sock. Is the Docker Daemon Running?
TLDR
If you see "Cannot connect to the Docker daemon at unix:/var/run/docker.sock", it usually means Docker isn't running or your user doesn't have permission. Start the Docker service or fix permissions to resolve it.
Prerequisites
- Docker installed
- Terminal access
- Sudo privileges (for some fixes)
Check if Docker is Running
First, check if the Docker daemon is active. On macOS, make sure Docker Desktop is running. On Linux, use:
# Check Docker service status (Linux)
systemctl status docker
If it's not running, start it:
# Start Docker service (Linux)
sudo systemctl start docker
On macOS, launch Docker Desktop from Applications.
Fix Permissions on the Docker Socket
If Docker is running but you still get the error, your user might not have permission to access the Docker socket. You can add your user to the docker group:
# Add your user to the docker group (Linux)
sudo usermod -aG docker $USER
# Log out and back in for the group change to take effect
On macOS, this is rarely needed, but restarting Docker Desktop can help.
Check for Stale or Broken Docker Socket
Sometimes the socket file can get corrupted. Remove it and restart Docker:
# Remove the socket file and restart Docker (Linux)
sudo rm /var/run/docker.sock
sudo systemctl restart docker
Visualizing the Docker Daemon Connection
+-------------------+
| docker client |
+-------------------+
|
v
+-------------------+
| /var/run/docker.sock |
+-------------------+
|
v
+-------------------+
| docker daemon |
+-------------------+
Next Steps
If you still have issues, check Docker logs or reinstall Docker. For CI environments, make sure the Docker service is started in your pipeline config.
Good luck with your project!
We earn commissions when you shop through the links below.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a SponsorFound an issue?
Related Posts
Also worth your time on this topic
Cannot Connect to Docker Daemon at unix:/var/run/docker.sock - Is the Docker Daemon Running?
Fix the common 'Cannot connect to the Docker daemon' error with practical solutions for Linux, macOS, and Windows. Learn why this happens and how to resolve permissions and service issues.
Running Docker Containers on Your Linux Server
Install Docker and Docker Compose on Ubuntu, run your first container, deploy a WordPress stack with docker-compose, and set up Nginx as a reverse proxy in front of your containers.
60 minutes
Using grep for Text Search
How do you use grep to search for text patterns in files? What are some useful flags?
junior