Podman Error: 'unable to connect to Podman socket' in Rootless and Docker-Compat Clients
Fix Podman's 'unable to connect to Podman socket' error: enable podman.socket, set DOCKER_HOST/CONTAINER_HOST, enable linger, and repair socket paths and permissions.
- #podman
- #containers
- #troubleshooting
- #errors
Stuck on this Podman error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
Exact Error Message
$ podman-remote ps
Error: unable to connect to Podman socket: failed to connect: dial unix
/run/user/1000/podman/podman.sock: connect: no such file or directory
Docker-compatible clients pointed at the same socket report it in their own dialect:
$ docker ps
Cannot connect to the Docker daemon at unix:///run/user/1000/podman/podman.sock.
Is the docker daemon running?
What It Means
Unlike Docker, Podman has no always-running daemon. The CLI normally forks the container runtime directly. But anything that speaks the Docker or libpod HTTP API — podman-remote, the docker CLI, docker compose, Testcontainers, the Docker SDKs, IDE plugins — needs a listening API endpoint. Podman provides one through podman system service, which systemd manages as a socket-activated unit. unable to connect to Podman socket means the client resolved a socket path and nothing was listening there, or the socket file existed but the client could not open it.
There are two entirely separate sockets, and confusing them is the most common root cause. The rootless per-user socket lives at $XDG_RUNTIME_DIR/podman/podman.sock (typically /run/user/1000/podman/podman.sock) and is created by the user unit podman.socket, enabled with systemctl --user. The rootful socket lives at /run/podman/podman.sock, is owned by root, and is managed by the system-level podman.socket unit. Containers started via the rootless socket run as your user with user-namespace ID mapping; containers started via the rootful socket run as root. A client configured for one will never see the other’s containers, and if you enable only the system unit while your tooling reads $XDG_RUNTIME_DIR, you get this error even though a Podman API is demonstrably running.
Common Causes
- The
podman.socketuser unit was never enabled, so nothing listens at$XDG_RUNTIME_DIR/podman/podman.sock. DOCKER_HOSTorCONTAINER_HOSTis unset, so a Docker-compat client falls back to/var/run/docker.sock, which does not exist.$XDG_RUNTIME_DIRis unset or wrong in cron jobs, CI runners, and non-login SSH sessions.- Lingering is disabled, so systemd tears down the user manager — and the socket — the moment the user logs out.
- The client is aimed at the rootful
/run/podman/podman.sockbut the user is not root and not in a group with access. - A stale
podman system connectionentry points at an old socket path or a dead SSH destination.
Diagnostic Commands
Check whether the socket unit is active and where it is listening:
systemctl --user status podman.socket
systemctl --user show podman.socket -p Listen
Confirm the socket file exists and inspect its ownership and mode:
ls -l "$XDG_RUNTIME_DIR/podman/podman.sock"
ls -l /run/podman/podman.sock 2>&1
Ask Podman itself which socket path it considers canonical:
podman info --format '{{.Host.RemoteSocket.Path}}'
podman info --format '{{.Host.RemoteSocket.Exists}}'
List the remote connections Podman has configured and which one is the default:
podman system connection list
Verify the environment your Docker-compat client actually sees:
echo "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
echo "DOCKER_HOST=$DOCKER_HOST"
echo "CONTAINER_HOST=$CONTAINER_HOST"
Step-by-Step Resolution
- Enable and start the rootless socket for your user. This is the fix for the overwhelming majority of cases:
systemctl --user enable --now podman.socket
systemctl --user status podman.socket
- Point Docker-compatible tooling at that socket.
DOCKER_HOSTcovers thedockerCLI, Compose, and most SDKs;CONTAINER_HOSTis whatpodman-remotereads:
export DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock"
export CONTAINER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock"
Persist it in ~/.bashrc or ~/.config/environment.d/podman.conf so it survives new shells.
- Enable lingering so the user’s systemd manager — and therefore the socket — stays up without an active login. This is mandatory for service accounts, build agents, and anything driven over SSH:
sudo loginctl enable-linger "$USER"
loginctl show-user "$USER" --property=Linger
- If you genuinely need the rootful socket (privileged ports, host networking, system-wide containers), enable the system unit and grant access deliberately rather than loosening permissions on the file:
sudo systemctl enable --now podman.socket
sudo ls -l /run/podman/podman.sock
export DOCKER_HOST="unix:///run/podman/podman.sock"
- Repair or recreate the Podman connection entry if
podman system connection listshows a stale target:
podman system connection remove default
podman system connection add --default rootless \
"unix://$XDG_RUNTIME_DIR/podman/podman.sock"
podman system connection list
- Verify end to end with both the native and the compatibility API:
podman --remote info --format '{{.Host.Arch}}'
curl -s --unix-socket "$XDG_RUNTIME_DIR/podman/podman.sock" \
http://d/v1.41/version
Testcontainers and similar libraries additionally require TESTCONTAINERS_RYUK_DISABLED=true on many rootless setups, since the reaper container expects to bind the Docker socket into itself. If your containers then fail to reach the network at all, check Podman error: netavark IO error, which covers the rootless networking state that lives beside the socket in $XDG_RUNTIME_DIR.
Prevention
- Enable
podman.socketandloginctl enable-lingeras part of provisioning any host that runs rootless workloads. - Export
DOCKER_HOSTfrom~/.config/environment.d/rather than an interactive shell rc, so systemd user units inherit it too. - Never
chmod 666the socket — it is a full container-control API; use the rootless per-user socket instead of sharing a rootful one. - Set
XDG_RUNTIME_DIRexplicitly in cron and CI job definitions, where it is routinely absent. - Keep one canonical
podman system connectionper host and remove stale entries when machines are rebuilt. - Prefer
podman --remoteover thedockershim in scripts you own, so failures name the real socket path.
Related Errors
Cannot connect to the Docker daemon at unix:///var/run/docker.sock— the client never picked upDOCKER_HOSTand used the Docker default path.permission deniedon/run/podman/podman.sock— you reached the rootful socket as an unprivileged user; use the rootless one.Error: unable to connect to Podman socket: ... connection refused— the socket file exists but the service failed to start; checksystemctl --user status podman.service.Failed to start podman.service: Unit not found— thepodmanpackage on that distro ships the API service separately; install the full package set.
Frequently Asked Questions
Do I need a Podman daemon running all the time? No. podman.socket is socket-activated: systemd holds the listening socket and only starts podman.service when a client connects, then lets it exit after an idle timeout. You get daemon-like API access without a persistent daemon.
Why does the socket disappear when I log out? Without lingering, systemd stops the user manager at logout and removes /run/user/<uid> along with everything in it. sudo loginctl enable-linger <user> keeps the user manager — and the socket — alive across logins and reboots.
Should I use the rootless or the rootful socket? Use rootless unless you have a concrete need for root-owned containers. Rootless containers run under your UID with user-namespace mapping and are far safer to expose to CI tooling. Mixing the two is why docker ps sometimes shows an empty list while podman ps shows containers.
Why does Docker Compose still fail after I set DOCKER_HOST? Compose spawns helpers that may not inherit an interactive-shell export, and some versions require the socket to be reachable at container start too. Set the variable in ~/.config/environment.d/podman.conf and re-login. For more rootless container fixes, see the Podman guides.
Fixed it? Get 500 Podman & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Did this fix your issue?
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.