glanceapp/glance · error
sending request to socket: %w
Error message
sending request to socket: %w
What it means
client.Do failed for the Docker API request — the TCP/Unix connection could not be established or timed out (5-second context). This is the most common Docker widget error: the socket file is missing, permission is denied, or the remote host is unreachable.
Source
Thrown at internal/glance/widget-docker-containers.go:327
return net.Dial("unix", source)
},
},
}
}
fetchAll := ternary(runningOnly, "false", "true")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
request, err := http.NewRequestWithContext(ctx, "GET", "http://"+hostname+"/containers/json?all="+fetchAll, nil)
if err != nil {
return nil, fmt.Errorf("creating request: %w", err)
}
response, err := client.Do(request)
if err != nil {
return nil, fmt.Errorf("sending request to socket: %w", err)
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, fmt.Errorf("non-200 response status: %s", response.Status)
}
var containers []dockerContainerJsonResponse
if err := json.NewDecoder(response.Body).Decode(&containers); err != nil {
return nil, fmt.Errorf("decoding response: %w", err)
}
for i := range containers {
container := &containers[i]
name := strings.TrimLeft(itemAtIndexOrDefault(container.Names, 0, ""), "/")
if name == "" {
continueView on GitHub (pinned to 91324e8de7)
Solutions
- Confirm the socket exists and is accessible: 'test -r /var/run/docker.sock && curl --unix-socket /var/run/docker.sock http://localhost/containers/json'
- Mount the socket into the glance container and/or add the user to the docker group
- For remote hosts, verify connectivity: 'nc -zv host 2375'; check firewall rules
- If timeouts recur, reduce Docker load or increase availability of the daemon
Example fix
# before
services:
glance:
image: glanceapp/glance
# after
services:
glance:
image: glanceapp/glance
volumes:
- /var/run/docker.sock:/var/run/docker.sock Defensive patterns
Strategy: retry
Validate before calling
if _, err := os.Stat(socketPath); err != nil {
return fmt.Errorf("docker socket %s unavailable: %w", socketPath, err)
} Try / catch
containers, err := fetchDockerContainersFromSource(socketPath, category, runningOnly, overrides)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) || strings.Contains(err.Error(), "connection refused") {
// transient daemon issue: skip this update cycle, keep last good data
return nil, errTransient
}
return nil, err
} Prevention
- Validate socket presence and writability at startup, not per update
- Mount /var/run/docker.sock read-only; keep glance user in the docker group
- Keep the 5s timeout — do not raise it to mask a dead daemon; alert instead
When it happens
Trigger: Dialing /var/run/docker.sock that does not exist or is not readable/writable by the glance process; remote tcp:// host refusing connections or firewalled; context deadline exceeded because Docker is unresponsive.
Common situations: Glance in a container without the socket mounted; socket owned by root:docker with glance not in the docker group; Podman socket at a different path; Docker daemon not started; NAT/firewall blocking port 2375/2376; Docker overloaded so the 5s timeout fires.
Related errors
- fetching containers: %w
- reading secret file: %v
- assets directory does not exist: %s
- parsing URL: %w
- creating request: %w
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/0b29a192de244923.
Report an issue: GitHub.