VPS Tutorials
Cannot Connect to Docker Daemon on a VPS: Service and Context (2026)
Confirm the selected endpoint, separate system and rootless Docker, diagnose startup logs and configuration, then verify original containers and volumes.

If docker ps, docker compose up or a deployment script reports Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, do not start by reinstalling Docker. It means the client did not connect to the daemon it selected. The service may be stopped, the endpoint wrong, rootless/system installations confused, or configuration preventing startup.
This guide targets systemd-based Linux VPS hosts: identify the endpoint, inspect service/logs, repair the cause and verify existing workloads. Desktop, Kubernetes runtimes and independently managed panel runtimes require their own service-location checks.
| Error/address | Investigate |
|---|---|
Cannot connect ... unix:///var/run/docker.sock | Local system daemon and selected socket |
/run/user/1000/docker.sock | Owner's rootless daemon and login session |
tcp://... / ssh://... | Context, environment and remote connection |
permission denied while trying to connect | Socket permission and identity, not necessarily a stopped service |
docker.service: Failed / Start request repeated too quickly | Earliest substantive journal failure |
Unit docker.service could not be found | CLI-only or a different installation/service model |
docker --version proves the CLI exists. docker version is more useful: a Client section with failed Server access leads to the checks below. See daemon troubleshooting.
Use the same user and terminal that failed:
docker version
docker context show
docker context ls
docker context inspect
env | grep -E '^DOCKER_(HOST|CONTEXT|TLS_VERIFY|CERT_PATH)='
Empty environment output normally means unset variables. Inspect the endpoint and error address. DOCKER_HOST, DOCKER_CONTEXT, --host and --context affect selection; the star in docker context ls alone is insufficient. See contexts.
For an intentional remote daemon, diagnose its host/SSH/TLS rather than silently switching locally. If this VPS should use the local system Engine, make a one-command comparison:
env -u DOCKER_HOST -u DOCKER_CONTEXT -u DOCKER_TLS_VERIFY -u DOCKER_CERT_PATH docker --context default info
It removes relevant endpoint environment settings and selects default for that command. If successful, repair the actual script/shell/CI source. Keep other Docker configuration and used remote contexts. sudo docker ... and ordinary users can read different accounts' contexts; success under sudo does not establish the same endpoint.
For a system-level Engine:
sudo systemctl status docker.service docker.socket --no-pager -l
sudo systemctl is-active docker.service
sudo journalctl -u docker.service -b --no-pager -n 100
sudo ls -l /var/run/docker.sock
A socket file does not prove a responding daemon. After confirming /var/run/docker.sock is correct, test explicitly:
sudo env -u DOCKER_HOST -u DOCKER_CONTEXT -u DOCKER_TLS_VERIFY -u DOCKER_CERT_PATH docker --host unix:///var/run/docker.sock info
If it works but the ordinary user gets permission denied on that same socket, follow socket/group permissions. Do not use chmod 666 /var/run/docker.sock; socket access normally grants powerful host control.
After confirming the system Engine and no configuration/data errors:
sudo systemctl start docker.service
sudo systemctl is-active docker.service
See daemon startup. If it fails, read logs instead of repeatedly retrying.
Check client and daemon separately:
command -v docker
command -v dockerd
systemctl list-unit-files 'docker*' 'containerd*'
docker alone does not install an Engine. Rootless, Snap, manual binaries and panels may use other management. Use the actual installation source without stacking conflicting packages. An improvised docker.service unit can complicate socket, containerd and argument behavior.
Read fuller logs and the effective unit:
sudo journalctl -u docker.service -b --no-pager -n 200
sudo systemctl cat docker.service
sudo systemctl show docker.service -p ExecStart -p FragmentPath -p DropInPaths
Failed to start Docker, exit-code and Start request repeated too quickly are outcomes. Search around dockerd first exiting for parse errors, duplicate options, write failures or network initialization. See daemon logs. Do not run a second dockerd while the system service remains active: competing sockets/PIDs/data directories introduce new failures.
The normal path is /etc/docker/daemon.json, unless ExecStart supplies --config-file. Check only an existing file:
sudo python3 -m json.tool /etc/docker/daemon.json
sudo dockerd --validate --config-file=/etc/docker/daemon.json
The first command checks JSON syntax; the second makes dockerd validate and exit. configuration OK does not prove storage/network/unit arguments work. See --validate in dockerd options. Do not create empty configuration just to run a check.
Before fixing a field, back up:
sudo cp -a /etc/docker/daemon.json /etc/docker/daemon.json.backup.$(date +%Y%m%d%H%M%S)
sudo nano /etc/docker/daemon.json
sudo dockerd --validate --config-file=/etc/docker/daemon.json
Look for trailing commas, comments, misspellings and unsupported copied templates. Retain data-root, storage and networking; replacing the file can point to another data directory and make existing containers appear missing.
For directives are specified both as a flag and in the configuration file: hosts, inspect systemctl cat docker.service for -H fd:///-H unix://... and JSON hosts. Duplicate options can prevent startup even with identical values. For a local-socket VPS, undo an unnecessary newly added hosts; intended custom endpoints need coordinated remote-access configuration.
Do not replace the original ExecStart=/usr/bin/dockerd with a stripped command that drops containerd/socket-activation/distribution arguments. Standalone JSON validation may miss conflicts with the unit; compare both and logs. Keep an unauthenticated public 2375 API closed.
For resource/network/storage initialization errors:
df -h
df -i
free -h
sudo journalctl -k -b --no-pager -n 200
Free gigabytes do not prevent inode exhaustion. OOM can kill the daemon. For operation not permitted, check whether VPS virtualization allows the required kernel capability. Repair the proven limit rather than disabling firewalls, changing drivers or formatting data. Never delete /var/lib/docker or actual data-root as a startup reset. docker system prune is not general recovery for an inaccessible daemon.
For /run/user/<UID>/docker.sock, or docker info showing rootless, inspect that owner's service instead of just sudo systemctl status docker. Log in directly as that user:
id -u
systemctl --user status docker.service --no-pager -l
journalctl --user -u docker.service -b --no-pager -n 100
docker context ls
After confirming installation and intended operation:
systemctl --user start docker.service
If rootless exists, verify it explicitly:
env -u DOCKER_HOST -u DOCKER_CONTEXT -u DOCKER_TLS_VERIFY -u DOCKER_CERT_PATH docker --context rootless info
Rootless uses ~/.config/docker/daemon.json and separate data. Its container inventory is not the system Engine's. See rootless usage. If systemctl --user reports Failed to connect to bus, user switching such as sudo su may lack a proper login session; retry from that user's normal SSH login. See rootless troubleshooting.
If the user service should run after logout/boot, assess and enable service/lingering:
systemctl --user enable docker.service
sudo loginctl enable-linger "$(id -un)"
Lingering permits logged-out services; it does not change the socket to /var/run/docker.sock. Clients still need the correct owner/endpoint.
After validation, use sudo systemctl daemon-reload if unit/drop-ins changed; JSON-only edits do not require it. Clear a failure-rate limit only after repairing the cause:
sudo systemctl reset-failed docker.service
sudo systemctl start docker.service
sudo systemctl is-active docker.service
sudo journalctl -u docker.service -b --no-pager -n 50
For a still-running daemon needing restart, plan the disruption. reset-failed clears failure state, not configuration/resource/permission problems.
Return to the originally failing user/environment:
docker version
docker info
docker ps -a
Read Server information, confirm the endpoint, retain original containers/volumes and test critical applications. active alone is insufficient. A remaining container restart loop needs that container's logs, not Engine reinstallation.