{"record":{"id":"297542b72816050d","repo":"hasura/graphql-engine","slug":"making-http-request-failed-w","errorCode":null,"errorMessage":"making http request failed: %w","messagePattern":"making http request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/util/server.go","lineNumber":138,"sourceCode":"\treturn state\n}\n\nfunc GetServerStatus(versionEndpoint string, httpClient *httpc.Client) (err error) {\n\tvar op errors.Op = \"util.GetServerStatus\"\n\n\treq, err := http.NewRequest(http.MethodGet, versionEndpoint, nil)\n\tif err != nil {\n\t\treturn errors.E(\n\t\t\top,\n\t\t\tfmt.Errorf(\"failed to create GET request to %s: %w\", versionEndpoint, err),\n\t\t)\n\t}\n\n\tvar responseBs bytes.Buffer\n\n\tresp, err := httpClient.Do(context.Background(), req, &responseBs)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"making http request failed: %w\", err))\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn errors.E(\n\t\t\top,\n\t\t\tfmt.Errorf(\n\t\t\t\t\"request failed: url: %s status code: %v status: %s \\n%s\",\n\t\t\t\tversionEndpoint,\n\t\t\t\tresp.StatusCode,\n\t\t\t\tresp.Status,\n\t\t\t\tresponseBs.String(),\n\t\t\t),\n\t\t)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/util/server.go#L120-L156","documentation":"GetServerStatus's HTTP round trip itself failed: httpClient.Do returned an error before receiving a response (cli/util/server.go:138). This wraps transport-level failures — DNS resolution, refused connections, TLS handshake errors, timeouts, or cancelled contexts — not HTTP error statuses.","triggerScenarios":"Calling GetServerStatus (used by the Validate and Execute command paths) when the server is not running, the host doesn't resolve, a TLS certificate is invalid, or the request exceeds the client's timeout.","commonSituations":"The backend server process is stopped or starting up; wrong host/port in config; self-signed cert without proper trust; firewall or proxy blocking the port; Kubernetes pod not ready; DNS entry missing in the environment.","solutions":["Verify the server is up and reachable: curl http://<host>:<port>/version from the same machine/env.","Fix host/port in the CLI config or start the server if it's local.","For TLS errors, install/trust the CA or point to the correct https endpoint.","Increase the HTTP client timeout if the endpoint is slow, and add retry with backoff for transient failures."],"exampleFix":"// before\nstatus, err := util.GetServerStatus(url)\nif err != nil { return err }\n\n// after\nvar status *Status\nerr := retry(3, time.Second, func() error {\n    var e error\n    status, e = util.GetServerStatus(url)\n    return e\n})\nif err != nil { return fmt.Errorf(\"server unreachable: %w\", err) }","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", hostPort, 2*time.Second)\nif err != nil { return fmt.Errorf(\"server not reachable: %w\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"var st *Status\nerr := retry(3, 500*time.Millisecond, func() error {\n    var e error\n    st, e = util.GetServerStatus(u)\n    return e\n})\nif err != nil { return fmt.Errorf(\"server unreachable after retries: %w\", err) }","preventionTips":["Health-check the server before running commands that depend on it.","Set a sane HTTP client timeout so failures surface quickly.","Add exponential backoff retry for transient network blips.","In Kubernetes, wait for readiness probes before invoking the CLI."],"tags":["go","http","network","connection-refused","timeout"],"backgroundTag":"connection-refused","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}