{"record":{"id":"0b29a192de244923","repo":"glanceapp/glance","slug":"sending-request-to-socket-w","errorCode":null,"errorMessage":"sending request to socket: %w","messagePattern":"sending request to socket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-docker-containers.go","lineNumber":327,"sourceCode":"\t\t\t\t\treturn net.Dial(\"unix\", source)\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\n\n\tfetchAll := ternary(runningOnly, \"false\", \"true\")\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\n\trequest, err := http.NewRequestWithContext(ctx, \"GET\", \"http://\"+hostname+\"/containers/json?all=\"+fetchAll, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating request: %w\", err)\n\t}\n\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"sending request to socket: %w\", err)\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"non-200 response status: %s\", response.Status)\n\t}\n\n\tvar containers []dockerContainerJsonResponse\n\tif err := json.NewDecoder(response.Body).Decode(&containers); err != nil {\n\t\treturn nil, fmt.Errorf(\"decoding response: %w\", err)\n\t}\n\n\tfor i := range containers {\n\t\tcontainer := &containers[i]\n\t\tname := strings.TrimLeft(itemAtIndexOrDefault(container.Names, 0, \"\"), \"/\")\n\n\t\tif name == \"\" {\n\t\t\tcontinue","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-docker-containers.go#L309-L345","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nservices:\n  glance:\n    image: glanceapp/glance\n# after\nservices:\n  glance:\n    image: glanceapp/glance\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock","handlingStrategy":"retry","validationCode":"if _, err := os.Stat(socketPath); err != nil {\n    return fmt.Errorf(\"docker socket %s unavailable: %w\", socketPath, err)\n}","typeGuard":null,"tryCatchPattern":"containers, err := fetchDockerContainersFromSource(socketPath, category, runningOnly, overrides)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) || strings.Contains(err.Error(), \"connection refused\") {\n        // transient daemon issue: skip this update cycle, keep last good data\n        return nil, errTransient\n    }\n    return nil, err\n}","preventionTips":["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"],"tags":["docker","connection","unix-socket","timeout"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}