ServerNeed — This Year's Best Offers For You

ServerNeed — More Than Hosting
Tutorials

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.

5 min read 13 views
Labelled network ports with blue cables
Table of Contents
  1. Before you start
  2. Step 1: Add your domain to Cloudflare
  3. Step 2: Check the imported records
  4. Step 3: Choose proxied or DNS only
  5. Step 4: Change nameservers at your registrar
  6. Step 5: Set the SSL/TLS mode
  7. Step 6: Check everything
  8. Troubleshooting after the move
  9. Example: a minimal record set for a cPanel-hosted site
  10. After moving: things to know
  11. Frequently Asked Questions
  12. Related reading
  13. 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

  1. Create or log in to a Cloudflare account (owned by your business).
  2. Choose Add a domain (or "Add site") and enter your domain.
  3. Choose a plan; the free plan includes DNS and basic proxy features.
  4. 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 for www);
  • 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:

  1. Open the domain's Nameservers setting.
  2. Replace the existing nameservers with Cloudflare's two.
  3. 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.

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

View All Articles