Diagnose by connection phase first
Every external browser or probe request passes through four strict phases in sequence. A failure in an earlier phase means later layers were never even reached.
| Failing phase | Common error seen by visitors | Real layer at fault | First check to run |
|---|---|---|---|
| 1. DNS lookup | DNS_PROBE_FINISHED_NXDOMAIN, SERVFAIL | Domain registrar expiry, broken nameservers, bad DNSSEC DS record, or deleted A/AAAA/CNAME record | Run a public DNS lookup and domain expiry check |
| 2. TCP connect | ERR_CONNECTION_REFUSED, ERR_CONNECTION_TIMED_OUT, Cloudflare 522 | Origin firewall blocking edge IPs, crashed web server daemon, full disk, or network outage | Verify web server process (nginx/caddy/apache2), port 80/443 firewall rules, and CDN IP allow-lists |
| 3. TLS handshake | ERR_CERT_DATE_INVALID, ERR_CERT_COMMON_NAME_INVALID, SSL_ERROR_BAD_CERT_DOMAIN | Expired Let’s Encrypt cert, broken HTTP-01 renewal behind redirect/WAF, or mismatched SNI vhost | Run the SSL certificate checker to inspect issuer, SAN hostnames, and expiry |
| 4. HTTP response | 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout, 429, 520–524 | Crashed PHP-FPM/Node/Gunicorn upstream, exhausted database connections, slow query timeout, or WAF rate-limiting | Inspect proxy error logs (nginx/caddy) alongside application memory, CPU, and DB pool saturation |
Check it now. The SSL certificate checker shows the issuer, the names, the expiry and the days left of a site’s certificate; the DNS lookup shows a domain’s A, AAAA, CNAME, NS and MX records. No account, and the address is not stored.
Exact triage playbooks for the five most common errors
1. HTTP 502 Bad Gateway
A 502 means your edge proxy (Nginx, Caddy, Apache, Cloudflare, or a load balancer) connected to the network successfully but received an invalid or closed response from the upstream application process.
- WordPress / PHP stacks: Check whether
php-fpmcrashed from an out-of-memory kill (dmesg | grep -i oom), a fatal error right after a plugin update, or a mismatched Unix socket path (fastcgi_pass). - Node.js / Next.js / Python stacks: Check
systemd/pm2/ container logs for crash loops after a recent deploy or missing environment variable. - Fast check: Compare the failure timestamp against your latest deploy or WordPress plugin update. If the proxy itself returns
502in under 10 milliseconds, the upstream socket is dead rather than slow.
2. HTTP 504 Gateway Timeout (and Cloudflare 524)
Unlike a fast 502, a 504 or Cloudflare 524 happens when the upstream accepted the TCP connection but failed to send response headers before the proxy timeout (typically 30 to 100 seconds).
- Database lock or pool exhaustion: A stuck migration, unindexed WooCommerce query, or unclosed connection pool stalls every incoming PHP/Node worker until the gateway gives up.
- Synchronous third-party API call on page render: Calling an external payment, shipping, or webhook API without a tight client timeout (2–5 seconds) turns a vendor slowdown into a full storefront outage.
- Fix pattern: Check slow-query logs and active worker counts (
php-fpmstatus,pg_stat_activity, or upstream latency percentiles), restart wedged workers only after capturing stack traces, and add strict upstream timeouts.
3. Cloudflare 522 Connection Timed Out
A 522 means Cloudflare reached the edge normally but its TCP SYN packet to your origin server timed out before completing a handshake.
- Cause A: A host firewall (
ufw,iptables,fail2ban, or hosting security software) began rate-limiting or dropping Cloudflare edge IP ranges. - Cause B: Origin CPU or memory is pegged at 100%, or the web server stopped listening on port 443.
- Fix pattern: Whitelist official Cloudflare IP ranges at the origin firewall, confirm the origin responds locally (
curl -I http://127.0.0.1), and check whether an active DDoS or scraper burst saturated origin workers.
4. SSL / TLS Errors (ERR_CERT_DATE_INVALID and SAN mismatches)
Almost all modern certificate outages are renewal failures, not missing initial setup.
- Why renewals break silently: A new redirect rule, Cloudflare proxy toggle, IPv6 AAAA record pointing to an old host, or aggressive WAF rule blocks
/.well-known/acme-challenge/30 days before expiry. Nobody notices until day 0 when browsers display a full-screen security warning. - Wrong hostname (
ERR_CERT_COMMON_NAME_INVALID): A site migrated to a new server withoutwwwin the certificate Subject Alternative Names (SAN), or the web server fell back to the default vhost certificate. - Fix pattern: Monitor certificate expiry at 30, 14, 7, and 1 day remaining, and inspect SAN names immediately after every domain or CDN cutover.
5. DNS Failures (NXDOMAIN and SERVFAIL)
DNS outages are the hardest to spot from inside the server because the origin host looks completely healthy while the outside world cannot reach it.
NXDOMAIN: Either the domain registration lapsed into registrar hold (clientHold/serverHold), or someone deleted the apexA/AAAAorCNAMErecord during a mail or hosting migration.SERVFAIL: Commonly caused by changing nameservers while an old DNSSECDSrecord remains published at the registrar, breaking cryptographic validation across recursive resolvers.- Fix pattern: Run a public DNS lookup from outside your office network, verify registrar status via RDAP, and keep DNS change history recorded next to every uptime check.
How Beamfar helps
Beamfar separates DNS, TCP connect, TLS handshake, redirect chain, and HTTP status on every check from two European regions (Falkenstein (Germany) and Helsinki (Finland)), and attaches DNS, certificate, redirect, and deploy-marker diffs right next to each confirmed incident. When a client site returns 502, 504, 522, an SSL failure, or NXDOMAIN, you receive the phase timings, likely cause, evidence, and client-ready draft summary in one view. Run an instant check with our website down checker or see how two-region checks work.
Questions
How can I tell quickly if a 502 or 522 error is only happening on my network or for all visitors?
Run the URL in our free website down checker, which executes a live external DNS, TCP, TLS, and HTTP check from outside your network and reports phase-by-phase timings without storing the address.
Why does a website show a 504 timeout when the server looks up in the hosting panel?
Because the operating system and web proxy are still running while upstream PHP-FPM, Node.js, or database workers are blocked waiting on locks or slow downstream calls beyond the gateway timeout.
Can an inside-WordPress plugin alert me during a 502, 522, or NXDOMAIN outage?
No. When DNS fails, TLS handshakes break, or PHP-FPM crashes with a 502, code inside WordPress cannot execute to send an alert. External multi-region monitoring verifies what real browsers actually receive.
What causes a sudden SERVFAIL right after changing nameservers?
Leaving a stale DNSSEC DS record active at the domain registrar after switching DNS providers causes validating resolvers to reject the entire zone until DNSSEC is disabled or updated with the new provider’s keys.
Sources
Read on . Standards and vendor pages change; confirm the current text before you rely on it.
- MDN Web Docs, HTTP response status codes (developer.mozilla.org)
- Cloudflare Docs, Troubleshooting 5xx errors (developers.cloudflare.com)
- Let’s Encrypt Documentation, Renewal and ACME challenges (letsencrypt.org)
- RFC 9110, HTTP Semantics (www.rfc-editor.org)