{"record":{"id":"d1928f3ec8f5597a","repo":"wtfutil/wtf","slug":"failed-to-connect-to-pi-hole-server-s","errorCode":null,"errorMessage":" failed to connect to Pi-hole server\n %s","messagePattern":" failed to connect to Pi-hole server\n (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/pihole/client.go","lineNumber":58,"sourceCode":"\t}\n\n\tvar query url2.Values\n\n\tif query, err = url2.ParseQuery(url.RawQuery); err != nil {\n\t\treturn status, fmt.Errorf(\" failed to parse query\\n %s\", parseError(err))\n\t}\n\n\tquery.Add(\"summary\", \"\")\n\n\turl.RawQuery = query.Encode()\n\tif req, err = http.NewRequest(\"GET\", url.String(), http.NoBody); err != nil {\n\t\treturn status, fmt.Errorf(\" failed to create request\\n %s\", parseError(err))\n\t}\n\n\tvar resp *http.Response\n\n\tif resp, err = c.Do(req); err != nil || resp == nil {\n\t\treturn status, fmt.Errorf(\" failed to connect to Pi-hole server\\n %s\", parseError(err))\n\t}\n\n\tdefer func() {\n\t\tif closeErr := resp.Body.Close(); closeErr != nil {\n\t\t\treturn\n\t\t}\n\t}()\n\n\tif resp.StatusCode >= http.StatusBadRequest {\n\t\treturn status, fmt.Errorf(\" failed to retrieve version from Pi-hole server\\n http status code: %d\",\n\t\t\tresp.StatusCode)\n\t}\n\n\tvar rBody []byte\n\n\tif rBody, err = io.ReadAll(resp.Body); err != nil {\n\t\treturn status, fmt.Errorf(\" failed to read status response\")\n\t}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/pihole/client.go#L40-L76","documentation":"Raised in getStatus when the HTTP client's Do call fails or returns a nil response — the Pi-hole server could not be reached (DNS failure, wrong host/port, connection refused, timeout) or returned no response object.","triggerScenarios":"Thrown at modules/pihole/client.go:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the Pi-hole host/address in apiUrl is reachable (ping/curl it)","Check DNS resolution and that the Pi-hole web server is running","Confirm no firewall blocks the connection and the port is correct","Increase timeouts if the server is slow to respond"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}