# Fix Cloudflare Error 522 (Connection Timed Out) – Step-by-Step
Getting a **Cloudflare 522** means Cloudflare reached your server’s IP but the connection to your origin didn’t complete. Below are the exact checks that fix it 9/10 times.
## 1) Confirm DNS points to the right place
- In Cloudflare → DNS, the hostname should point to your origin (A/AAAA) or a Cloudflare Tunnel (CNAME to *.cfargotunnel.com).
- If you’re using a home server, use **Cloudflare Tunnel** and remove old A/AAAA records.
## 2) Open ports on your origin
On Ubuntu:
```bash
sudo ufw allow 80,443/tcp
sudo ufw status
Ensure hosting provider / router allows inbound 80/443 (or use Cloudflare Tunnel to avoid port forwarding).
3) Check your web server locally
sudo systemctl status nginx --no-pager -l
ss -tulpen | grep ':80\|:443'
curl -I http://localhost
You should see 200 OK
or a WordPress redirect.
4) Fix SSL mode mismatches
- Flexible (no cert on origin) can cause loops if your app forces HTTPS.
- Prefer Full (or with Tunnel, terminate SSL at Cloudflare and serve HTTP on origin).
- Behind proxies, set WordPress to trust the forwarded protocol:
// wp-config.php
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
5) Using Cloudflare Tunnel (no router configs)
Install and auth cloudflared
, create a tunnel, and add CNAME DNS records for your domain to <uuid>.cfargotunnel.com
. In /etc/cloudflared/config.yml
:
tunnel: <YOUR_TUNNEL_UUID>
credentials-file: /home/<user>/.cloudflared/<YOUR_TUNNEL_UUID>.json
ingress:
- hostname: yourdomain.com
service: http://localhost:80
- hostname: www.yourdomain.com
service: http://localhost:80
- service: http_status:404
Run as a service:
sudo cloudflared service install
sudo systemctl enable --now cloudflared
6) Common quick wins
- Remove duplicate/conflicting Nginx server blocks for the same server_name.
- Ensure the app’s Site URL =
https://yourdomain.com
. - Clear Cloudflare cache and browser cookies after changes.
Need help? Use the comments or the contact form and I’ll add the exact commands for your setup.
Publish ✅
# 6) homepage & menu
– Appearance → Customize → Homepage Settings → set **Your latest posts** (simple)
– Appearance → Menus → add links to Categories (WordPress, Nginx & Cloudflare, etc.)
# 7) get indexed (free traffic)
**Search Console**
1) Go to Google Search Console
2) Add **Domain property**: `offlinesupports.com`
3) Verify via **DNS TXT** (add it in Cloudflare → DNS)
4) In Search Console → Sitemaps → add: `sitemap_index.xml` (Rank Math provides it)
**Google Analytics (optional now, great later)**
– Install **Site Kit by Google** plugin OR paste GA4 tag via Rank Math → Analytics
# 8) monetization (start when you have ~10 helpful posts)
– **AdSense**: sign up, paste code into Ad Inserter Block 1 → auto insert before paragraph 3
– **Affiliate**: join programs relevant to your guides (domain/hosting, VPNs, hardware, etc.)
– Create a simple **Disclosure** page (legal) and link it in footer
# 9) speed & Cloudflare quick wins
Cloudflare Dashboard:
– Speed → **Brotli: ON**
– Speed → **Auto Minify: ON** (HTML/CSS/JS)
– Rocket Loader: **OFF** (can break WP editors)
– Caching → **Standard**; Purge Everything after theme/major changes
# 10) security & backups
– Wordfence: keep updated, scan weekly
– UpdraftPlus: verify remote backups actually appear in Google Drive/Dropbox
– Users → your admin account: use a strong password (store it safely)