DB / Docker / Connection Refused
CRITICAL
Docker Docker Daemon Connection Failure
The Docker client cannot communicate with the Docker daemon. This typically means the daemon is not running, is misconfigured, or the client lacks proper permissions to access its socket.
Common Causes
- The Docker daemon (dockerd) service is not running.
- The current user lacks permissions to access the Docker Unix socket (/var/run/docker.sock).
- The DOCKER_HOST environment variable is incorrectly set, pointing to a wrong or unreachable endpoint.
- A firewall or security group is blocking the network port if connecting via TCP.
How to Fix
1 Start the Docker Daemon
Ensure the Docker service is running on your system.
BASH
$ sudo systemctl start docker
# Verify the service status
sudo systemctl status docker 2 Add User to Docker Group
Add your user to the 'docker' group to grant socket access without sudo. Remember to log out and back in for changes to apply.
BASH
$ sudo usermod -aG docker $USER 3 Check and Unset DOCKER_HOST
If you are not intentionally using a remote Docker daemon, unset the DOCKER_HOST variable to default to the local Unix socket.
BASH
$ echo $DOCKER_HOST
# If it points to a TCP address (e.g., tcp://...), unset it
unset DOCKER_HOST 4 Test Daemon Connection with Sudo
Use sudo to test if the issue is purely a permission problem. If this works, refer to the 'Add User to Docker Group' solution.
BASH
$ sudo docker info