googleapis/mcp-toolbox · error
error performing request: %w
Error message
error performing request: %w
What it means
Thrown by the Dgraph source's healthCheck when hc.httpClient.Do(req) fails, meaning the HTTP GET to the Dgraph /health endpoint could not be completed. The underlying transport error (DNS, dial, timeout, TLS) is wrapped with %w. This signals a network-level failure reaching the Dgraph Zero/Alpha, not an HTTP error status.
Source
Thrown at internal/sources/dgraph/dgraph.go:354
hc.AccessJwt = r.Data.AccessJWT
hc.RefreshToken = r.Data.RefreshJWT
return nil
}
func (hc *DgraphClient) healthCheck() error {
url, err := getUrl(hc.baseUrl, "/health", nil)
if err != nil {
return err
}
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
return fmt.Errorf("error creating request: %w", err)
}
resp, err := hc.httpClient.Do(req)
if err != nil {
return fmt.Errorf("error performing request: %w", err)
}
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
var result []struct {
Instance string `json:"instance"`
Address string `json:"address"`
Status string `json:"status"`
}
// Unmarshal response into the struct
if err := json.Unmarshal(data, &result); err != nil {
return fmt.Errorf("failed to unmarshal json: %v", err)
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Verify Dgraph is running and reachable: curl http://<host>:<port>/health from the toolbox host/container.
- Correct the baseUrl host/port in the Dgraph source configuration.
- If containers are involved, confirm both are on the same Docker/Kubernetes network.
- If intermittent, retry; persistent failures indicate connectivity or service-down issues.
Example fix
// before baseUrl: http://localhost:8080 // dgraph runs in another container // after baseUrl: http://dgraph:8080 // use the service name on the shared network
Defensive patterns
Strategy: retry
Validate before calling
// reachability probe before initializing the source
resp, err := http.Get("http://dgraph:8080/health")
if err != nil {
return fmt.Errorf("dgraph unreachable at :8080: %w", err)
}
resp.Body.Close() Try / catch
if err := healthCheck(ctx); err != nil {
if strings.Contains(err.Error(), "error performing request") {
// transient network failure: retry with backoff
return retryWithBackoff(3, 2*time.Second, healthCheck)
}
return err
} Prevention
- Verify network reachability (curl /health) from the toolbox host before wiring the source.
- Place toolbox and Dgraph on the same Docker network / Kubernetes namespace.
- Set reasonable HTTP client timeouts and monitor Dgraph container health.
- Use service DNS names (e.g. http://dgraph:8080) rather than localhost in containerized setups.
When it happens
Trigger: healthCheck calls hc.httpClient.Do(req) against baseUrl + "/health" and the request fails before a response is returned: connection refused, DNS resolution failure, TLS handshake error, or context deadline exceeded.
Common situations: Dgraph container not running or crashed, wrong host/port in baseUrl, service in a different Docker network/namespace, firewall or network policy blocking the port, or the health check timing out under load.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- failed to fetch OIDC config: %w
- failed to read introspection response: %w
- failed to read response body: %w
- failed to execute request: %w
- error parsing JSON: %v
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/986e944a662506f7.
Report an issue: GitHub.