# permission denied while trying to connect to the Docker daemon socket

> The user running `docker` (or an agent running it for you) cannot write to `/var/run/docker.sock`, which is owned by root and the `docker` group. The exact message, why Docker prints it, and the fix.

_Updated November 23, 2026_

## The message

```text
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.47/containers/json": dial unix /var/run/docker.sock: connect: permission denied
```

## What it means

The user running `docker` (or an agent running it for you) cannot write to `/var/run/docker.sock`, which is owned by root and the `docker` group.

## Fix

1. Add the user to the group: `sudo usermod -aG docker $USER`, then log out and back in (or run `newgrp docker`).
2. Check the socket: `ls -l /var/run/docker.sock` should show group `docker`.
3. Avoid `chmod 666` on the socket: it gives every user root-equivalent control of the host.

## In an EnvHaven workspace

Plus and Pro workspaces include Docker with access already set up. Hobby workspaces include the Docker client but no daemon.

## Where this comes from

This message was produced by Docker itself, in a throwaway EnvHaven 1.9.0 container, on 2026-11-23; the text above is copied from that output.

## Keep reading

- [Every agent error](https://envhaven.com/errors)

Source: https://envhaven.com/errors/docker/permission-denied-docker-daemon-socket
