Setting up Cloudflare with your cPanel hosting account can feel overwhelming when you're new to web hosting. You'll encounter terms like nameservers, DNS records, and proxy status without clear explanations of what they mean or what to do with them. This guide walks you through the entire process from zero, defines every concept you'll meet, and shows you how to troubleshoot the most common errors beginners encounter.
What You're Actually Setting Up
Before diving into steps, let's clarify what Cloudflare and cPanel are, and why you'd connect them.
cPanel is a control panel that comes with most shared hosting accounts. It's the dashboard where you manage your website files, email accounts, databases, and domain settings. Your hosting provider installs cPanel on their servers and gives you login credentials.
Cloudflare is a content delivery network (CDN) and security service that sits between your visitors and your hosting server. When someone visits your website, their request goes to Cloudflare's global network first. Cloudflare then decides whether to serve a cached copy of your page or forward the request to your actual hosting server.
When you integrate Cloudflare with cPanel hosting, you're changing where the internet looks for your website's IP address. Instead of pointing directly to your hosting server, your domain's DNS records will point to Cloudflare, and Cloudflare will route traffic to your server.
Prerequisites You Need
Before starting, gather these items:
- A registered domain name that you own
- Active cPanel hosting account with login credentials
- Access to your domain registrar account (where you originally purchased the domain)
- A Cloudflare account (free tier works fine)
You'll need the ability to change nameservers at your domain registrar. Some registrars lock nameservers for newly transferred domains for a few days; if yours is locked, wait for the lock period to expire.
Step 1: Create and Configure Your Cloudflare Account
Go to Cloudflare's website and create a free account. After verifying your email, Cloudflare will ask you to add a site.
- Enter your domain name exactly as it appears (example.com, not www.example.com)
- Select the Free plan when prompted
- Cloudflare will scan your existing DNS records
This scan attempts to import all current DNS records from your domain. The scan usually takes 30-60 seconds. Once complete, you'll see a list of DNS records Cloudflare found.
Step 2: Review and Verify DNS Records
Cloudflare will present a table of DNS records. Each row represents one record with several columns:
- Type: The kind of record (A, CNAME, MX, TXT, etc.)
- Name: The subdomain or @ for the root domain
- Content: The destination (usually an IP address or hostname)
- Proxy status: An orange cloud (proxied) or gray cloud (DNS only)
The most critical records for beginners:
A records point your domain to an IP address. You should see at least one A record for your root domain (@) and often one for www. These will point to your cPanel server's IP address.
MX records handle email routing. If you use email with your domain through cPanel, these must point to your hosting provider's mail servers. Cloudflare typically detects these correctly.
CNAME records create aliases. Common examples include cpanel.yourdomain.com or webmail.yourdomain.com pointing to your main domain.
Checking Your Current Server IP in cPanel
To verify Cloudflare imported the correct IP address:
- Log into cPanel
- Find "Server Information" or "General Information" in the sidebar
- Look for "Shared IP Address" or "Server IP"
- Compare this IP to the Content field of your @ and www A records in Cloudflare
If they don't match, Cloudflare may have scanned outdated records. Manually correct the A records in Cloudflare to use your cPanel server's IP address.
Proxy Status: Orange vs Gray Cloud
Each DNS record has a cloud icon you can click:
- Orange cloud (proxied): Traffic routes through Cloudflare's network. You get caching, DDoS protection, and your server's real IP is hidden. Use this for web traffic (HTTP/HTTPS).
- Gray cloud (DNS only): Cloudflare acts as a DNS provider only; traffic goes directly to your server. Use this for email, FTP, SSH, and cPanel access.
For a basic setup:
- A record for @ (root domain): Orange cloud
- A record for www: Orange cloud
- MX records for email: Gray cloud (always)
- CNAME for cpanel or webmail: Gray cloud
- Any FTP or mail subdomains: Gray cloud
Leaving cPanel-related subdomains on gray cloud prevents issues accessing your control panel after the switch.
Step 3: Change Nameservers at Your Registrar
After reviewing DNS records, Cloudflare will display two nameservers that look like:
ns1.cloudflare.com
ns2.cloudflare.com
Your specific nameservers will have different prefixes (like aron.ns.cloudflare.com). Copy both exactly.
Now go to your domain registrar (GoDaddy, Namecheap, Google Domains, etc.) and locate the nameserver settings. The exact steps vary by registrar, but generally:
- Log into your registrar account
- Find your domain in the domain list
- Look for "Nameservers", "DNS Settings", or "Domain Settings"
- Choose "Custom nameservers" or "Use custom DNS"
- Replace existing nameservers with Cloudflare's two nameservers
- Save changes
The registrar may warn that changing nameservers will affect DNS. Confirm and proceed.
Propagation time: DNS changes take time to spread across the internet. Cloudflare will send you an email when your domain is active on their network. This usually takes 15 minutes to 24 hours, though most changes complete within a few hours.
Step 4: Wait for Activation and Verify
During propagation, your website will still work. Visitors may reach your site via the old nameservers or the new Cloudflare nameservers depending on their location and ISP.
To check if the switch is complete:
nslookup -type=NS yourdomain.com
Or use an online DNS checker tool. When you see Cloudflare's nameservers in the response, the change has propagated to that DNS server.
Cloudflare's dashboard will show "Active" next to your domain once it detects the nameserver change. You'll also receive an email confirmation.
Common Errors and How to Fix Them
Error 1: Website Shows "This site can't be reached"
Cause: The A records in Cloudflare point to the wrong IP address, or the IP address changed.
Fix:
- Log into cPanel and verify your current server IP
- Go to Cloudflare DNS settings
- Edit the A record for @ and www to match your cPanel server IP exactly
- Wait 5 minutes for changes to apply
Error 2: SSL/TLS Certificate Errors or "Too Many Redirects"
Cause: Mismatched SSL settings between Cloudflare and cPanel.
Fix:
- In Cloudflare, go to SSL/TLS settings
- Set encryption mode to "Flexible" temporarily if your cPanel doesn't have an SSL certificate yet
- If cPanel already has an SSL certificate (AutoSSL or Let's Encrypt), use "Full" mode
- Never use "Full (strict)" with cPanel's AutoSSL unless you're certain the certificate is installed and valid
Redirect loop specifically: Check cPanel for redirect rules in .htaccess that force HTTPS. If Cloudflare's SSL is on "Flexible" and cPanel forces HTTPS, you'll create a loop. Either disable the cPanel HTTPS redirect or upgrade Cloudflare SSL to "Full".
Error 3: Email Stops Working After Switching Nameservers
Cause: MX records are missing, incorrect, or accidentally proxied through Cloudflare.
Fix:
- Go to Cloudflare DNS settings
- Verify all MX records are present and match your hosting provider's mail server hostnames
- Ensure MX records show gray cloud (DNS only), never orange cloud
- Common cPanel mail server format is mail.yourdomain.com with priority 0
- Check with your hosting provider's documentation for exact MX record values
Error 4: Can't Access cPanel or Webmail
Cause: The subdomain for cPanel (cpanel.yourdomain.com or yourdomain.com:2083) either doesn't have a DNS record or is proxied through Cloudflare.
Fix:
- In Cloudflare DNS, ensure you have a CNAME or A record for cpanel pointing to your domain or server IP
- Set this record to gray cloud (DNS only)
- Alternatively, access cPanel using your server's hostname or IP address directly: https://server-ip:2083
- Some hosts provide a dedicated hostname like server123.yourhost.com for cPanel access
Error 5: Cloudflare Shows "Pending Nameserver Update"
Cause: The nameserver change hasn't propagated yet, or you entered incorrect nameservers at your registrar.
Fix:
- Double-check you entered Cloudflare's nameservers exactly as provided (copy-paste is safer than typing)
- Verify you removed all old nameservers from your registrar; some registrars require you to delete old entries before adding new ones
- Check registrar lock status; some registrars lock domains for a transfer protection period
- Wait 24-48 hours; propagation can be slow with some registrars
- Use an online DNS propagation checker to see how far the change has spread globally
Error 6: Some Images or CSS Not Loading
Cause: Mixed content issues (HTTPS page loading HTTP resources) or overly aggressive Cloudflare cache.
Fix for mixed content:
- In Cloudflare, go to SSL/TLS tab
- Enable "Automatic HTTPS Rewrites" under Edge Certificates
- This rewrites HTTP links to HTTPS automatically
Fix for cache issues:
- Go to Cloudflare Caching tab
- Click "Purge Everything" to clear all cached content
- Wait a few minutes and reload your website
- For persistent issues, temporarily set Development Mode to "On" which pauses caching for 3 hours
Error 7: "Error 521: Web server is down"
Cause: Cloudflare can reach your domain's IP address, but your hosting server isn't responding on port 80 (HTTP) or 443 (HTTPS).
Fix:
- Verify your hosting server is actually running; check with your hosting provider
- Confirm the IP address in Cloudflare's A records matches your current cPanel server IP exactly
- Check if your hosting provider's firewall blocks Cloudflare IPs; some hosts require you to whitelist Cloudflare's IP ranges
- Temporarily set the A record to gray cloud to test if your server responds without Cloudflare
Post-Setup: Recommended Cloudflare Settings for cPanel Hosting
Once your site is working through Cloudflare:
Enable automatic HTTPS rewrites (SSL/TLS → Edge Certificates → Automatic HTTPS Rewrites: On)
Turn on "Always Use HTTPS" if you want all HTTP requests redirected to HTTPS (SSL/TLS → Edge Certificates → Always Use HTTPS: On)
Configure Page Rules for cPanel and webmail subdomains:
- Go to Rules → Page Rules
- Create a rule for
cpanel.yourdomain.com/* - Add setting: "Cache Level" → "Bypass"
- Save and deploy
This ensures Cloudflare never caches your cPanel login pages.
Review Caching settings: For most websites, the default caching is fine. If you run a WordPress site or update content frequently, you may want to adjust cache TTL or set up cache purge automation.
Check Firewall settings: Cloudflare's free plan includes basic firewall rules. The default "Medium" security level works for most sites. If you see legitimate visitors blocked, review Security → Events to see what triggered blocks and adjust rules accordingly.
Verifying Everything Works
Website Access
Visit your site in a browser. Try both http://yourdomain.com and https://www.yourdomain.com. Both should load correctly and show a padlock icon if SSL is configured.
Email Test
Send a test email to an address at your domain and send one from that address to an external email. Both directions should work without delays.
cPanel Access
Log into cPanel using your normal URL (yourdomain.com:2083 or cpanel.yourdomain.com). If you can't access it via domain, use your server IP or hostname as an alternative.
Check Cloudflare Analytics
Cloudflare's Analytics tab will start showing traffic after a few hours. This confirms traffic is flowing through their network.
Conclusion
Integrating Cloudflare with cPanel hosting involves changing your domain's nameservers, verifying DNS records, and configuring SSL settings correctly. The most common errors stem from incorrect IP addresses in DNS records, mismatched SSL settings between Cloudflare and cPanel, and accidentally proxying services that should use DNS-only mode. By following the steps in this guide, checking each setting carefully, and using gray cloud for email and cPanel access, you'll avoid the majority of problems beginners encounter. Once set up correctly, Cloudflare provides caching, security, and performance benefits with minimal ongoing maintenance. If you run into issues not covered here, Cloudflare's support documentation and your hosting provider's support team are your next resources.
