cloudflare/cloudflared · error
API call to %s failed with status %d: %s
Error message
API call to %s failed with status %d: %s
What it means
Fallback HTTP failure in RESTClient.statusCodeToError: the API responded with a status that is neither 200 nor one of the mapped sentinel statuses (400/401/403/404) and the body carried no parseable JSON errors. The error names the operation, status code, and its HTTP text (e.g. 429, 500, 502).
Source
Thrown at cfapi/base_client.go:241
var errorsResp response
if json.NewDecoder(resp.Body).Decode(&errorsResp) == nil {
if err := errorsResp.checkErrors(); err != nil {
return errors.Errorf("Failed to %s: %s", op, err)
}
}
}
switch resp.StatusCode {
case http.StatusOK:
return nil
case http.StatusBadRequest:
return ErrBadRequest
case http.StatusUnauthorized, http.StatusForbidden:
return ErrUnauthorized
case http.StatusNotFound:
return ErrNotFound
}
return errors.Errorf("API call to %s failed with status %d: %s", op,
resp.StatusCode, http.StatusText(resp.StatusCode))
}
View on GitHub (pinned to 2253eeeb25)
Solutions
- For 429, back off and retry — rate limited by the Cloudflare API.
- For 5xx, retry later; the failure is server-side.
- Check the operation name and status in the message before escalating.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at cfapi/base_client.go:241 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/515299993b5d2489.
Report an issue: GitHub.