{"record":{"id":"e4731e8a049e02fd","repo":"rqlite/rqlite","slug":"server-responded-with-s-e4731e","errorCode":null,"errorMessage":"server responded with %s","messagePattern":"server responded with (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/rqlite/main.go","lineNumber":566,"sourceCode":"\nfunc expvar(ctx *cli.Context, client *httpcl.Client, line string) error {\n\tu := fmt.Sprintf(\"%sdebug/vars\", client.Prefix)\n\treturn cliJSON(ctx, client, line, u)\n}\n\nfunc reap(ctx *cli.Context, client *httpcl.Client) error {\n\tu := fmt.Sprintf(\"%sreap\", client.Prefix)\n\tresp, err := client.Post(u, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode == http.StatusUnauthorized {\n\t\treturn fmt.Errorf(\"unauthorized\")\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"server responded with %s\", resp.Status)\n\t}\n\n\tvar result map[string]int\n\tif err := json.NewDecoder(resp.Body).Decode(&result); err != nil {\n\t\treturn fmt.Errorf(\"failed to decode response: %s\", err)\n\t}\n\tctx.String(\"snapshots reaped: %d, WALs checkpointed: %d\\n\",\n\t\tresult[\"snapshots_reaped\"], result[\"wals_checkpointed\"])\n\treturn nil\n}\n\nfunc snapshot(client *httpcl.Client, trailingLogs int) error {\n\tu := fmt.Sprintf(\"%ssnapshot?trailing_logs=%d\", client.Prefix, trailingLogs)\n\tresp, err := client.Post(u, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/rqlite/rqlite/blob/7586a4d1bdbd9a5a80021664c5a863cd850adb60/cmd/rqlite/main.go#L548-L584","documentation":"The 'reap' command POSTs to /reap and expects HTTP 200. Any other status (apart from 401, handled earlier) produces this error carrying the HTTP status line. Unlike the leader command, the response body is not included — only the status string (e.g. '503 Service Unavailable').","triggerScenarios":"POST /reap returns a non-200/401 status — e.g. 404 on an rqlited version without the reap endpoint, 405 if routed through a misconfigured proxy, or 5xx while the node is busy or unhealthy.","commonSituations":"Older rqlited binary lacking the /reap endpoint; reverse proxy blocking POST; node overloaded or returning 500 during snapshot/checkpoint work.","solutions":["Check the HTTP status in the message to identify the failure kind (404 vs 5xx).","Upgrade rqlited if /reap is unsupported in your version.","Curl the endpoint directly to see the response body/details.","Check rqlited logs for the server-side error accompanying a 5xx."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"resp, err := client.Post(u, nil)\nif err != nil { return err }\nif resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusUnauthorized {\n    return fmt.Errorf(\"/reap not available (HTTP %d) — check rqlited version\", resp.StatusCode)\n}","typeGuard":"null","tryCatchPattern":"if err := reap(ctx, client); err != nil {\n    if strings.Contains(err.Error(), \"server responded with 404\") {\n        return fmt.Errorf(\"/reap unsupported on this rqlited version; upgrade\")\n    }\n    return err\n}","preventionTips":["Keep CLI and rqlited versions in sync.","Check the HTTP status code embedded in the message before retrying.","Avoid proxies that strip or reject POSTs to the API.","Watch rqlited logs for 5xx causes."],"tags":["http","cli","http-status"],"backgroundTag":"unexpected-http-status","analyzedSha":"7586a4d1bdbd9a5a80021664c5a863cd850adb60","analyzedAt":"2026-09-03T07:03:02.260Z","contentChangedAt":"2026-09-03T07:03:02.260Z","schemaVersion":2},"datasetVersion":"2026-09-10T12:17:11.382Z"}