{"record":{"id":"5e7b7a910e33ccda","repo":"amir20/dozzle","slug":"healthcheck-failed-with-status-code-d","errorCode":null,"errorMessage":"healthcheck failed with status code %d","messagePattern":"healthcheck failed with status code (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/healthcheck/http.go","lineNumber":38,"sourceCode":"\turl := fmt.Sprintf(\"%s%s/healthcheck\", addr, base)\n\n\tif !strings.HasPrefix(url, \"http\") {\n\t\turl = \"http://\" + url\n\t}\n\n\tlog.Info().Str(\"url\", url).Msg(\"performing healthcheck\")\n\tresp, err := http.Get(url)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode == 200 {\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"healthcheck failed with status code %d\", resp.StatusCode)\n}\n","sourceCodeStart":20,"sourceCodeEnd":40,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/healthcheck/http.go#L20-L40","documentation":"HttpRequest in the healthcheck probes its own /healthcheck endpoint and treats any HTTP status other than 200 as a failure. The server is reachable (http.Get succeeded) but returned an error status (e.g. 500 or 503), signaling the Dozzle process is not healthy. This message is a format string; the actual status code is filled in at runtime.","triggerScenarios":"HttpRequest performs a GET against the configured healthcheck URL and the server returns a non-200 status, e.g. the app is behind auth returning 401, the path moved (301), or the service is failing (500/503).","commonSituations":"Healthcheck URL points to an endpoint behind an auth proxy (401/302 redirect to login), wrong port or path after a refactor (404), or the container is up but crashing on requests (500).","solutions":["Log/inspect the returned status code to identify the cause (4xx vs 5xx)","Point the healthcheck URL at an unauthenticated endpoint like /healthz or /ping","Fix the path/port if the app returns 404 after reconfiguration","If the endpoint is protected, add the required credentials or allowlist the healthcheck path","If a redirect is expected, follow redirects or accept 2xx-3xx in your own check"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(healthURL)\nif err == nil {\n    if resp.StatusCode != http.StatusOK {\n        return fmt.Errorf(\"pre-check: endpoint returned %d\", resp.StatusCode)\n    }\n}","typeGuard":null,"tryCatchPattern":"err := healthcheck.HttpRequest(ctx, url)\nif err != nil {\n    var he *statusError // or match on the message\n    if strings.Contains(err.Error(), \"status code 4\") {\n        // auth/routing problem: fix URL or credentials\n    } else if strings.Contains(err.Error(), \"status code 5\") {\n        // server problem: retry with backoff\n    }\n}","preventionTips":["Expose a dedicated unauthenticated /healthz endpoint","Verify healthcheck URLs after any auth-proxy or route changes","Distinguish 4xx (config problem) from 5xx (service problem) when alerting"],"tags":["healthcheck","http","status-code"],"backgroundTag":"http-error-status","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}