When you set up Cloudflare for WordPress, you put a fast, protective layer between your visitors and your server — for free. Cloudflare handles your DNS, serves your images, CSS, and JavaScript from nearby data centers, blocks a large share of automated attacks, and issues a free SSL certificate. This guide walks through the full setup, including the SSL setting that breaks the most WordPress sites.
What Cloudflare Does for a WordPress Site
Cloudflare is a reverse proxy: visitors connect to its network first, and it fetches content from your server on their behalf. The free plan includes a CDN caching static files at 300+ edge locations, fast DNS, a free SSL certificate, unmetered DDoS protection, and a firewall with a free managed ruleset plus five custom WAF rules.
Just as important is what Cloudflare does not do. By default it does not cache your HTML pages — every page view still runs PHP and MySQL on your origin server until you add APO or a cache rule (Step 6). It does not fix slow hosting, and it does not replace updates or backups.
Before You Start
This guide is for self-hosted WordPress — a WordPress.org site where you control your own domain and DNS. WordPress.com free and lower-tier plans cannot change nameservers. Before you set up Cloudflare for WordPress, you need access to your domain registrar, a valid SSL certificate on your host (most hosts offer free Let’s Encrypt certificates), and a backup of your site plus a copy of your current DNS records.
Step 1: Create a Cloudflare Account and Add Your Site
- Go to cloudflare.com and create a free account with your email address and a strong password.
- Click Add a Site and enter your domain name only —
yoursite.com, withouthttps://orwww. - When asked for a plan, pick Free. It covers everything in this guide, and you can upgrade later without touching DNS again.
- Cloudflare scans your domain’s existing DNS records and offers to import them.
Step 2: Check Your Imported DNS Records
Do not rush past this screen — most Cloudflare migrations go wrong here. A and CNAME records for your domain and www must point at your hosting server; a missing or wrong A record takes your site down when the nameservers change. MX records for your email must be present and correct — a missing MX record is the number one way people break their email during a Cloudflare migration.
Each record shows a proxy status: orange cloud means traffic passes through Cloudflare, grey means DNS only. Leave website records orange; set email records (MX targets, mail subdomain) to grey cloud — proxying them breaks email.
Step 3: Change Your Nameservers at Your Registrar
Cloudflare gives you two nameservers, something like dana.ns.cloudflare.com and rex.ns.cloudflare.com. Log in to your registrar and replace the existing nameservers with the two Cloudflare gives you. DNS changes take time to propagate — usually minutes to a few hours, up to 24 hours worst case. Your site stays up during the switch: some visitors still reach your old DNS directly, the rest reach Cloudflare. Cloudflare shows your domain as Active once the change has been detected.
Step 4: Set SSL to Full (Strict) and Turn On Always Use HTTPS
This step breaks more WordPress sites than any other. In the Cloudflare dashboard, go to SSL/TLS and pick a mode. Off means no encryption — never use it live. Flexible encrypts only the visitor-to-Cloudflare leg, and it is the classic cause of redirect loops: WordPress redirects to HTTPS, Cloudflare passes it back as HTTP, and the loop never ends. Full encrypts both legs without checking your origin certificate. Full (strict) encrypts both legs and verifies the certificate on your host. Choose Full (strict), then switch on Always Use HTTPS under SSL/TLS → Edge Certificates.
Then check WordPress: in Settings → General, both addresses must start with https://. If your host has no valid certificate, Cloudflare offers a free Origin CA certificate lasting up to 15 years. If you hit a redirect loop, read my guide on how to fix the WordPress redirect loop.
Step 5: Install the Official Cloudflare Plugin and Connect with an API Token
In WordPress, go to Plugins → Add New, search for “Cloudflare”, and install the official plugin. It has more than 200,000 active installs and needs WordPress 6.7+ and PHP 7.4+ (current version 4.14.5, October 2026). After activation, connect it with an API token — not the old email-and-API-key combination. In your Cloudflare dashboard, go to My Profile → API Tokens → Create Token and use the WordPress template. Never use the Global API Key: it opens your entire Cloudflare account.
Once connected, turn on Auto Purge Content On Update: when you publish or edit a post, the plugin purges the cached copy so visitors see the new version. The plugin also restores real visitor IPs in comments and analytics — without it, every visitor appears to come from a Cloudflare IP.
Step 6: Cache Your HTML — APO or a Cache Rule (Pick One)
Out of the box, Cloudflare caches only static files — your HTML pages still come from your origin server on every visit. To serve full pages from the edge, pick one of two options — never both.
Option A: Automatic Platform Optimization (APO) — $5/month on Free
APO is Cloudflare’s purpose-built cache for WordPress: it caches your full HTML pages at the edge, so a whole page can be served from a nearby data center without touching your server. On the free plan it costs $5 per month per domain; it is included with Pro and higher plans. Pro costs $20 per month billed annually and includes APO. It caches HTML for up to 30 days and purges a changed page within about 30 seconds of an update. Logged-in users, session cookies, and WooCommerce cookies bypass the cache, so editors see live pages and shoppers see their own carts. It never caches checkout, wp-cron.php, or feeds, and does not support multisite.
Option B: A Cache Rule — free
If you would rather not pay the $5, a single Cache Rule can cache your HTML instead. The free plan allows 10 cache rules, and WordPress needs one. The free Super Page Cache plugin creates and manages this rule for you, because a wrong hand-written rule can cache logged-in pages or cart contents for the wrong visitors. Whichever route you choose, disable any other full-page caching plugin first: two page caches cause stale content and hard-to-diagnose bugs. WooCommerce store? Read my WooCommerce setup guide first so you know which pages must never be cached.
After enabling either option, test logged out: load a page twice and check the cf-cache-status header in your browser’s developer tools — HIT means the edge served it. To dig deeper, see my guide on how to reduce server response time in WordPress.
Recommended Cloudflare Settings for WordPress
Most defaults are sensible. Under Speed → Optimization, turn on Early Hints, HTTP/3, and Brotli, and leave Rocket Loader off — it breaks more WordPress sites than it speeds up. Under Caching, turn on Smart Tiered Caching. Under Security → WAF, leave the free managed ruleset on and use your five custom rules on real WordPress attacks: challenge repeated wp-login.php attempts, block xmlrpc.php. See my WordPress security hardening checklist for a broader pass. Set Minimum TLS Version to 1.2, and leave Bot Fight Mode off if you run forms or logins. Auto Minify was retired in 2024, and Page Rules were replaced by Cache Rules.
Common Cloudflare WordPress Problems (and Fixes)
Redirect loop after setup
Almost always Flexible SSL. Switch to Full (strict) as in Step 4 and confirm both WordPress URLs use https://.
Changes do not show on the site
You are looking at a cached page. In the dashboard go to Caching → Purge Cache → Purge Everything.
Error 521 or 522
Cloudflare cannot reach your origin server: a 521 means the origin refused the connection, a 522 means it timed out. Check your host is up, then whitelist Cloudflare’s IP ranges in your host firewall.
Frequently Asked Questions
Does Cloudflare replace a WordPress security plugin?
No. Cloudflare blocks many attacks at the edge, but it cannot patch a vulnerable plugin, enforce strong passwords, or scan your files.
Setting up Cloudflare takes about 30 minutes plus DNS propagation, and for most WordPress sites it is the highest-value free performance and security upgrade available. Get the SSL mode right, connect the plugin with an API token, and pick one HTML caching method. Done right, when you set up Cloudflare for WordPress, speed and security stop being things you worry about.
If you would rather have an expert handle the setup — or your site is already on Cloudflare and something is misbehaving — get in touch. I build and speed up WordPress sites every week, and a correct Cloudflare setup is usually the first thing I fix.