How to Set Up Cloudflare DNS for Your Domain
Move your domain's DNS to Cloudflare step by step: add the site, check imported records, change nameservers at your registrar, choose proxied or DNS-only, set SSL mode and keep email working.

Table of Contents
- Before you start
- Step 1: Add your domain to Cloudflare
- Step 2: Check the imported records
- Step 3: Choose proxied or DNS only
- Step 4: Change nameservers at your registrar
- Step 5: Set the SSL/TLS mode
- Step 6: Check everything
- Troubleshooting after the move
- Example: a minimal record set for a cPanel-hosted site
- After moving: things to know
- Frequently Asked Questions
- Related reading
- Sources
To use Cloudflare for DNS: create a Cloudflare account and add your domain, review the DNS records Cloudflare imports (especially MX and TXT records for email), change your domain's nameservers at your registrar to the two Cloudflare nameservers you are given, and set the SSL/TLS mode to Full (strict) once your server has a valid certificate. Decide for each record whether traffic is proxied through Cloudflare (orange cloud) or DNS only (grey cloud).
Cloudflare's dashboard changes over time, so menu names may differ slightly from those below.
Before you start
- Log in details for your domain registrar.
- A list of your current DNS records, from your current DNS host. This is your safety net if anything is missed.
- A valid SSL certificate on your hosting server (see how to install a free SSL certificate in cPanel).
Step 1: Add your domain to Cloudflare
- Create or log in to a Cloudflare account (owned by your business).
- Choose Add a domain (or "Add site") and enter your domain.
- Choose a plan; the free plan includes DNS and basic proxy features.
- Cloudflare scans your existing DNS records.
Step 2: Check the imported records
Compare Cloudflare's list with your own list. Make sure these are present and correct:
- A records for the root domain and
www(or a CNAME forwww); - MX records for email, with correct priorities;
- TXT records: SPF, DKIM, DMARC and any verification records;
- records for subdomains and services (
mail,webmail,cpanel,ftp, apps).
Add anything missing before going further. Missing email records are the most common cause of trouble.
Step 3: Choose proxied or DNS only
| Setting | Use for |
|---|---|
| Proxied (orange cloud) | Website records (@, www): traffic passes through Cloudflare for caching and protection, and your server IP is hidden |
| DNS only (grey cloud) | Mail server records (mail), FTP, SSH, cPanel/WHM and other non-web services, which the proxy does not carry |
MX records always point to hostnames that must be DNS-only. If you proxy the root domain, make sure your mail hostname is a separate DNS-only record.
Step 4: Change nameservers at your registrar
Cloudflare shows two nameservers (for example name1.ns.cloudflare.com). At your registrar:
- Open the domain's Nameservers setting.
- Replace the existing nameservers with Cloudflare's two.
- Save.
If your domain has DNSSEC enabled at the registrar, turn it off before changing nameservers, then enable DNSSEC in Cloudflare and add the new DS record at the registrar afterwards. Otherwise the domain may fail to resolve.
The change can take a few hours to be seen everywhere. Cloudflare emails you when the domain is active. See DNS propagation explained.
Step 5: Set the SSL/TLS mode
In SSL/TLS settings:
- Full (strict): Cloudflare connects to your server over HTTPS and verifies its certificate. Use this when your server has a valid certificate.
- Full: HTTPS to the server without strict verification.
- Flexible: HTTP to your server. Avoid it; it leaves the server connection unencrypted and commonly causes redirect loops.
Then enable Always Use HTTPS. See how to force HTTPS and fix mixed content.
Step 6: Check everything
- Website loads over HTTPS on both root and
www - Email sends and receives (test both ways)
- cPanel, webmail and FTP still reachable (DNS-only records)
- SSL renewals on your server still succeed (AutoSSL may need HTTP validation to reach the origin; Full (strict) with a valid certificate usually works)
Troubleshooting after the move
| Problem | Likely cause | Fix |
|---|---|---|
| "Too many redirects" | SSL mode set to Flexible while the server also redirects to HTTPS | Use Full (strict) with a valid origin certificate |
| Email stopped | MX or mail hostname missing, or mail hostname proxied | Add the records; set mail records to DNS only |
| cPanel or webmail unreachable | Their hostnames proxied, or the records missing | Add DNS-only records for them |
| Site shows Cloudflare error 521 or 522 | Cloudflare cannot reach your server | Check the server is up and allows Cloudflare's IP ranges |
| Error 526 | Invalid certificate on the origin with Full (strict) | Fix or reissue the origin certificate |
| Changes in cPanel Zone Editor have no effect | DNS is now answered by Cloudflare | Make changes in Cloudflare |
| Domain not resolving after the switch | DNSSEC left on at the registrar with the old DS record | Remove the DS record at the registrar, then re-enable DNSSEC via Cloudflare |
Example: a minimal record set for a cPanel-hosted site
| Type | Name | Content | Proxy |
|---|---|---|---|
| A | @ |
Hosting IP | Proxied |
| CNAME | www |
example.com |
Proxied |
| A | mail |
Hosting IP | DNS only |
| MX | @ |
mail.example.com (priority 0 or 10) |
— |
| TXT | @ |
SPF record | — |
| TXT | default._domainkey |
DKIM key from cPanel | — |
| TXT | _dmarc |
DMARC policy | — |
| A | cpanel, webmail |
Hosting IP | DNS only |
Copy the actual values from your current zone; the table shows which records need to exist and how they should be proxied.
After moving: things to know
- Make DNS changes in Cloudflare from now on, not at your old DNS host or in cPanel's Zone Editor.
- Caching: by default Cloudflare caches static files, not HTML. Purge the cache after major changes.
- Real visitor IPs: when proxied, your server sees Cloudflare's IP addresses; configure your server or application to read the real visitor IP from Cloudflare's headers, trusting them only from Cloudflare's IP ranges.
- Origin protection: consider allowing web traffic to your server only from Cloudflare's ranges, so attackers cannot bypass the proxy.
Frequently Asked Questions
Does Cloudflare make my site faster?
It can, by serving static files from nearby locations and reducing load on your server. It does not fix slow uncached pages. See website caching explained.
Will moving DNS cause downtime?
Not if all records are copied correctly before changing nameservers. Both the old and new DNS answer during the switch.
Should I proxy my mail records?
No. Mail and other non-web services must be DNS-only.
Related reading
See nameservers vs DNS records and DDoS attacks explained. Manage your domain with the ServerNeed domain search.
For how DNS works behind the scenes, see what is DNS.
Sources
Last updated 7 October 2026



