Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Retry-After, Rate Limits, and RFC 9457 Error Responses

How Retry-After and rate-limit headers work on Cloudflare edge errors and REST APIs, plus Brave and Perplexity 429 handling and safe retry logic.

Most of this page draws on Cloudflare documentation for proxied-site error pages and the Cloudflare REST API. It also covers how the Brave Search API rate limiting guide and Perplexity rate limits tell clients to back off when quotas are exceeded. The shared idea is simple: read standard headers (especially Retry-After and rate-limit fields), parse structured error bodies when offered, and retry only when the response says it is safe.

When you need Retry-After and rate-limit headers

Section titled “When you need Retry-After and rate-limit headers”

You are building or operating an HTTP client—dashboard automation, search integration, or an agent that hits sites behind a CDN—when responses come back as 429 Too Many Requests, Cloudflare 1xxx errors, or Cloudflare-generated 5xx errors. The practical questions are whether to retry, how long to wait, who owns the failure, and how much quota remains. Headers and structured bodies exist so you do not have to scrape HTML error pages.

Retry-After: what it signals and when it appears

Section titled “Retry-After: what it signals and when it appears”

Retry-After is a standard HTTP response header. On retryable failures it gives a recommended wait time in seconds before calling again.

Cloudflare states for generated 1xxx errors:

Cloudflare-generated 1xxx error responses now include a standard Retry-After HTTP header when the error is retryable. Agents and HTTP clients can read the recommended wait time from response headers alone — no body parsing required.

— Cloudflare, Retry-After HTTP header for retryable 1xxx errors

For Cloudflare-generated 5xx errors (not responses passed through from your origin), retryable codes include Retry-After matching the retry_after field in JSON or Markdown; 525 and 526 (TLS problems) do not send the header. Origin-generated 5xx responses that Cloudflare forwards unchanged are not covered by this structured format—see Error responses.

When a WAF rate limiting rule already set a dynamic Retry-After, that value wins over Cloudflare’s default for the error code—documented in the 1xxx Retry-After changelog and error responses reference.

Retry-After on Cloudflare proxied errors (1xxx and 5xx)

Section titled “Retry-After on Cloudflare proxied errors (1xxx and 5xx)”

The error responses reference lists default retry_after seconds for retryable codes. Changelog material also documents seven retryable 1xxx codes with headers; the reference table lists six (it does not include 1005).

Code retry_after (seconds) Error name (reference)
1004 120 DNS resolution error
1015 30 Rate limited
1033 120 Argo Tunnel error
1038 60 HTTP headers limit exceeded
1200 60 Cache connection limit
1205 5 Too many redirects

Changelog entries additionally list 1005 (Banned zone) with 120 seconds—see Retry-After HTTP header for retryable 1xxx errors.

Code retry_after (seconds)
500 30
502 60
504 120
520 60
521 120
522 120
523 120
524 120
525 N/A (not retryable)
526 N/A (not retryable)

For 5xx, the error_category field tells you how to treat retries—origin faults (e.g. 502, 504, 520–524) are transient with backoff; ssl (525, 526) means do not retry until TLS is fixed—per Structured error responses for Cloudflare 5xx errors.

Retry-After on Cloudflare REST API 429 responses

Section titled “Retry-After on Cloudflare REST API 429 responses”

For the Cloudflare REST API, quota headers are always present; Retry-After appears only after you exceed a limit (429):

Returned only when a rate limit has been reached (error code: 429): Retry-After: Number of Seconds until more capacity is available, rounded up

— Cloudflare, Introducing new headers for rate limiting on Cloudflare’s API

The API limits reference names the same behavior (retry-after when the request has exceeded the rate limit). These headers apply to REST APIs only, not GraphQL—see the rate limiting changelog.

How Brave Search and Perplexity expose wait times

Section titled “How Brave Search and Perplexity expose wait times”

Brave Search API documents a 1-second sliding window and 429 on exceed; it steers clients toward X-RateLimit-Reset (seconds until each quota window resets) rather than quoting Retry-After on every response—see Rate Limiting. For 429, the guide recommends reading reset headers and using exponential backoff.

Perplexity states that Orchestrator and Agent APIs return 429 with Retry-After when rate limited or upstream overloaded, and that 429 rejections are not billed—Rate Limits & Usage Tiers. Agent API 429 bodies use error.type (request_rate_limit_exceeded, token_rate_limit_exceeded, overloaded); those responses include Retry-After but not x-ratelimit-* headers.

Common conclusion: Prefer Retry-After when present (Cloudflare edge errors, Cloudflare API 429, Perplexity 429). On Brave, combine X-RateLimit-Remaining and X-RateLimit-Reset to pace traffic before you hit 429; after 429, use reset values plus backoff as in Implement Retry Logic.

Structured error responses (RFC 9457) on Cloudflare

Section titled “Structured error responses (RFC 9457) on Cloudflare”

By default, Cloudflare error pages are HTML. Clients that send structured Accept values get machine-readable bodies instead:

When Cloudflare cannot complete a request, it generates an error response. The format depends on what the client requests via the Accept header and on the zone’s Custom Errors configuration.

— Cloudflare, Error responses

Structured responses cover all Cloudflare-generated 1xxx errors and Cloudflare-generated 5xx (500, 502, 504, 520–526). Send Accept: application/json or Accept: application/problem+json for JSON following RFC 9457 (type, status, title, detail, instance), or Accept: text/markdown for Markdown with YAML frontmatter—see JSON responses and RFC 9457 support for Cloudflare 1xxx errors and Markdown responses for Cloudflare 1xxx errors.

Cloudflare-specific fields include error_code, error_name, error_category, retryable, retry_after, what_you_should_do, and cloudflare_error (always true for these responses)—table in Error responses — Cloudflare extension members. Zones with Custom Errors may override what clients receive.

1xxx vs HTTP status: Proxied-site 1xxx codes often appear in the HTML body while the HTTP status may be 4xx or 5xx depending on the error—see Cloudflare 1xxx errors.

Rate-limit headers: Cloudflare REST API vs Brave Search API

Section titled “Rate-limit headers: Cloudflare REST API vs Brave Search API”
Aspect Cloudflare REST API Brave Search API
Policy headers Ratelimit, Ratelimit-Policy (IETF draft pattern) X-RateLimit-Limit, X-RateLimit-Policy
Remaining quota In Ratelimit (r= remaining, t= reset) X-RateLimit-Remaining (comma-separated per window)
After limit hit Retry-After on 429 429; use X-RateLimit-Reset per Rate Limiting
SDK behavior Latest Cloudflare SDKs backoff automatically Application must implement pacing
Scope REST only, not GraphQL Brave API plans (1s burst + monthly quota)

Cloudflare documents examples such as Ratelimit: "default";r=50;t=30 and Ratelimit-Policy: "burst";q=100;w=60 in Introducing new headers for rate limiting on Cloudflare’s API.

Brave notes that only successful responses count toward quota and billing—X-RateLimit-Remaining.

Retry logic: provider rules and safe patterns

Section titled “Retry logic: provider rules and safe patterns”

Retry 429, 500, 503, and 507 responses only when repeating the query is safe for your application. Use bounded exponential backoff with jitter. If a 429 response includes Retry-After, do not retry before that interval has elapsed.

— Cloudflare, Error responses (Analytics SQL API)

Do not retry 400, 403, 422, or 501 without fixing credentials, permissions, or the query.

Brave’s service docs repeat integration-level habits that reduce rate-limit and transient errors:

  • Answers — Error Handling: retry logic for transient failures; check spending limits; handle rate limits gracefully.
  • Autosuggest: debounce requests; cache repeated queries; design around plan rate limits.
  • LLM Context: 30-second timeout; exponential backoff; respect the 1-second sliding window and rate limit headers.

For pagination, Web Search recommends using more_results_available instead of blind offset increases to avoid useless calls.

Read error.type on 429, wait Retry-After, then retry with backoff; distinguish request QPS limits from token TPM/TPH limits—Rate Limits & Usage Tiers.

  • Retrying 525 / 526 or non-retryable 1xxx codes when retryable is false or Retry-After is absent.
  • Ignoring Retry-After and using a fixed sleep (Perplexity and Cloudflare SQL API docs explicitly warn against retrying before the header interval).
  • Treating Cloudflare GraphQL like REST for Ratelimit / automatic SDK backoff—REST-only per changelog.
  • Parsing HTML error pages when sending Accept: application/json would return RFC 9457 JSON from /cdn-cgi/error/{code} test URLs in Error responses.
  • Assuming 1020 means any block: WAF blocks use the WAF response, not 1020—Error 1020.
  1. Request structured JSON for a known retryable code on your proxied zone, e.g. follow Test structured error responses against https://<your-domain>/cdn-cgi/error/1015 with Accept: application/json and confirm retryable and retry_after in the body.

  2. Dump response headers on the same URL and confirm Retry-After matches the body, as in Verify Retry-After for 1xxx errors.

  3. Call a Cloudflare REST API endpoint and inspect Ratelimit and Ratelimit-Policy on a successful response; if you can safely trigger 429 in a test account, confirm Retry-After—API limits and rate limiting changelog.

  4. On a Brave Search API call, read X-RateLimit-Remaining and X-RateLimit-Reset from a normal response per Rate Limiting.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about so it can be corrected or explained.