Opyntel

Cloudflare 502 Bad Gateway and 52x errors

A 5xx from Cloudflare, such as a Cloudflare 502 Bad Gateway, means one of two things. Either your Worker or Pages Function threw an error, or Cloudflare could not get a good answer from your origin server. Cloudflare reports origin problems with its own 520 to 526 codes. It charts both kinds, but its error-rate alerts are for Enterprise plans only.

Cloudflare 502 Bad Gateway

A 502 page with Cloudflare’s branding means the problem was inside Cloudflare, and usually clears by itself. A 502 without it came from your origin, passed through unchanged: the app behind it failed. See 502 Bad Gateway for how to trace it.

Cloudflare’s 52x codes

CodeWhat happened
520The origin returned an empty, unknown or unexpected response
521The origin refused the connection: the web server is down or blocks Cloudflare
522The connection to the origin timed out
523The origin is unreachable: a DNS or routing problem
524The origin accepted the connection but did not answer in time
525The TLS handshake between Cloudflare and the origin failed
526The origin’s certificate is not valid

Where Cloudflare shows them

Zone analytics break traffic down by status code. Workers and Pages Functions show requests and errors per script in their metrics.

What Cloudflare does not alert on below Enterprise

Cloudflare’s Origin Error Rate and Advanced Error Rate notifications are available on Enterprise plans only. On other plans, a Worker or an origin can fail a share of its requests without a notification.

How Opyntel alerts on Cloudflare errors

Opyntel reads requests and errors for every Worker and Pages Function from Cloudflare’s analytics API and alerts you when a Worker’s error rate crosses your threshold, on any Cloudflare plan, by email, Slack or SMS depending on your plan. Your Workers sit on one dashboard with the origins they call, whether those run on Railway, Coolify or a Hetzner server.

FAQ

Cloudflare 5xx questions, answered

502 pages, 52x codes and error-rate alerts.

If the page carries Cloudflare’s branding, the problem was in Cloudflare. If not, your origin returned the 502 and the app behind it failed.

With 522, Cloudflare could not connect to the origin in time. With 524, it connected but the origin did not answer in time.

Its error-rate notifications are for Enterprise plans. Opyntel alerts on Worker error rate on any Cloudflare plan.

The alerts your platform doesn’t send.

One dashboard for everything you run, with the alerts your platforms leave out. Read-only, nothing to install in your apps.

See how it works