What Is a 523 Status Code?
A 523 status code is a Cloudflare error, "Origin is unreachable", returned when Cloudflare has no network route to the origin server’s IP address. It usually means the A or AAAA record in Cloudflare DNS points at the wrong IP, or a router or cloud route table between Cloudflare and the origin is dropping the traffic.
- Code
- 523
- Name
- Origin Is Unreachable
- Class
- Cloudflare extension
- Retry?
- Yes, with backoff
What causes error 523?
- →An A or AAAA record in Cloudflare DNS pointing at an old or wrong IP.
- →A routing problem between Cloudflare and the origin network.
- →In AWS, an overly broad VPC route (such as
172.0.0.0/8) capturing traffic meant for Cloudflare’s172.64.0.0/13range.
How do you fix error 523 when web scraping?
- →Retry later. A 523 is a network or DNS problem on the site’s side and nothing in your request will change it.
- →Use a cached copy of the page if you need the content now.
How do you fix error 523 on your own server?
- →Confirm the origin IP in your A and AAAA records.
- →Check routing between the origin and Cloudflare, including cloud route tables.
- →Ask your host for an MTR or traceroute from the origin to a Cloudflare IP that used to connect.
How do you handle error 523 in a retry loop?
fetch() treats 523 as temporary. It waits for Retry-After when the server sends a number of seconds, otherwise backs off exponentially with jitter, caps every wait at 60 seconds, and gives up after five attempts.
import random
import time
import requests
RETRYABLE = {408, 429, 500, 502, 503, 504, 520, 521, 522, 523, 524}
def fetch(url: str, max_attempts: int = 5) -> requests.Response:
for attempt in range(max_attempts):
try:
response = requests.get(url, timeout=(10, 60))
except requests.Timeout:
time.sleep(2**attempt + random.uniform(0, 1))
continue
if response.status_code not in RETRYABLE:
response.raise_for_status()
return response
retry_after = response.headers.get("Retry-After", "")
backoff = 2**attempt + random.uniform(0, 1)
time.sleep(min(int(retry_after) if retry_after.isdigit() else backoff, 60))
raise RuntimeError(f"Gave up on {url} after {max_attempts} attempts")
How does Context.dev handle error 523?
Context.dev retries the fetch for you, and by default Scrape can reuse a capture made in the last 3 days (maxAgeMs), so a page that is briefly down may still come back from cache. If no capture is available, the failed output carries an error_code and message inside an HTTP 200 response, and a request where every output fails is not charged.
See what the web scraping API does on every request, or read how to fix HTTP errors in web scraping for a longer walkthrough.
Frequently asked questions about error 523
What does Cloudflare error 523 mean?
Cloudflare cannot reach the site’s origin server at the network level, usually because DNS points at the wrong IP or a route is missing.
How do I fix error 523 on my site?
Check the origin IP in Cloudflare DNS first. If it is correct, trace the route from your origin to Cloudflare and check firewall and cloud route tables.
Is 523 the same as 522?
No. A 523 means there is no route at all. A 522 means the route exists but the connection timed out.
Which status codes are related to 523?
Sources
Last reviewed