{"record":{"id":"4eb8156651447b13","repo":"dgraph-io/dgraph","slug":"http-fetch-v","errorCode":null,"errorMessage":"http fetch: %v","messagePattern":"http fetch: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/debuginfo/debugging.go","lineNumber":89,"sourceCode":"\tout, err := os.Create(filePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error while creating debug file: %s\", err)\n\t}\n\tdefer func() {\n\t\tout.Close()\n\t}()\n\t_, err = io.Copy(out, resp)\n\treturn err\n}\n\n// fetchURL fetches a profile from a URL using HTTP.\nfunc fetchURL(source string, timeout time.Duration) (io.ReadCloser, error) {\n\tclient := &http.Client{\n\t\tTimeout: timeout,\n\t}\n\tresp, err := client.Get(source)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"http fetch: %v\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\tdefer func() {\n\t\t\tif err := resp.Body.Close(); err != nil {\n\t\t\t\tglog.Warningf(\"error closing body: %v\", err)\n\t\t\t}\n\t\t}()\n\t\treturn nil, statusCodeError(resp)\n\t}\n\n\treturn resp.Body, nil\n}\n\nfunc statusCodeError(resp *http.Response) error {\n\tif resp.Header.Get(\"X-Go-Pprof\") != \"\" &&\n\t\tstrings.Contains(resp.Header.Get(\"Content-Type\"), \"text/plain\") {\n\t\tif body, err := io.ReadAll(resp.Body); err == nil {\n\t\t\treturn fmt.Errorf(\"server response: %s - %s\", resp.Status, body)","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/debuginfo/debugging.go#L71-L107","documentation":"fetchURL performs an HTTP GET against an internal admin endpoint (e.g. /health or /state on an Alpha) when collecting debug info. If the request fails at the transport level, the error is wrapped as 'http fetch: %v'. Non-200 status codes are handled separately, so this specifically means the request never completed.","triggerScenarios":"Running `dgraph debuginfo --alpha_addr <addr>` when the Alpha is down, the address/port is wrong, the connection is refused/timed out, DNS fails, or TLS is required but http:// was used (or vice versa).","commonSituations":"Cluster stopped before collecting debug info, wrong --alpha_addr (default localhost:8080) in distributed setups, firewall blocking the port, or querying an HTTPS-only Alpha over plain HTTP.","solutions":["Verify the Alpha is running and reachable: curl http://<alpha_addr>/health","Correct the --alpha_addr host/port (default is http://localhost:8080)","Check network/firewall rules between the debuginfo client and the Alpha, and use the right scheme (http vs https)","Retry after the cluster is healthy"],"exampleFix":"// before\ndgraph debuginfo --alpha_addr localhost:9080  # gRPC port, not HTTP\n// http fetch: ... connection refused\n// after\ndgraph debuginfo --alpha_addr localhost:8080","handlingStrategy":"retry","validationCode":"addr := *alphaAddr\nif _, err := net.DialTimeout(\"tcp\", strings.TrimPrefix(strings.TrimPrefix(addr, \"http://\"), \"https://\"), 3*time.Second); err != nil {\n    return fmt.Errorf(\"alpha %s unreachable: %v\", addr, err)\n}\n// also sanity check: curl http://<alpha_addr>/health before dgraph debuginfo","typeGuard":null,"tryCatchPattern":"// Go pattern for callers wrapping fetchURL\nbody, err := fetchURL(source, timeout)\nif err != nil {\n    var nerr net.Error\n    if errors.As(err, &nerr) && nerr.Timeout() { /* retry with backoff */ }\n    return fmt.Errorf(\"http fetch: %v\", err)\n}","preventionTips":["Confirm the Alpha is up (curl http://<alpha>/health) before dgraph debuginfo","Use the HTTP port (default 8080), not the gRPC port (9080), in --alpha_addr","Check firewall/security-group rules between client and Alpha","Match the scheme: use https:// if the Alpha serves TLS","Add retry with backoff around debuginfo collection in automation"],"tags":["network","http","connectivity","diagnostics"],"backgroundTag":"http-request-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}