wtfutil/wtf · error

failed to connect to Pi-hole server %s

Error message

 failed to connect to Pi-hole server
 %s

What it means

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.

Source

Thrown at modules/pihole/client.go:58

	}

	var query url2.Values

	if query, err = url2.ParseQuery(url.RawQuery); err != nil {
		return status, fmt.Errorf(" failed to parse query\n %s", parseError(err))
	}

	query.Add("summary", "")

	url.RawQuery = query.Encode()
	if req, err = http.NewRequest("GET", url.String(), http.NoBody); err != nil {
		return status, fmt.Errorf(" failed to create request\n %s", parseError(err))
	}

	var resp *http.Response

	if resp, err = c.Do(req); err != nil || resp == nil {
		return status, fmt.Errorf(" failed to connect to Pi-hole server\n %s", parseError(err))
	}

	defer func() {
		if closeErr := resp.Body.Close(); closeErr != nil {
			return
		}
	}()

	if resp.StatusCode >= http.StatusBadRequest {
		return status, fmt.Errorf(" failed to retrieve version from Pi-hole server\n http status code: %d",
			resp.StatusCode)
	}

	var rBody []byte

	if rBody, err = io.ReadAll(resp.Body); err != nil {
		return status, fmt.Errorf(" failed to read status response")
	}

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Verify the Pi-hole host/address in apiUrl is reachable (ping/curl it)
  2. Check DNS resolution and that the Pi-hole web server is running
  3. Confirm no firewall blocks the connection and the port is correct
  4. Increase timeouts if the server is slow to respond
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at modules/pihole/client.go:58 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/d1928f3ec8f5597a. Report an issue: GitHub.