Cloudflare Pages makes it possible to publish static websites and front-end projects using a hosted website address. If you already own a domain name, you can connect it to your Pages project so visitors can access your website through your own web address instead of a default pages.dev URL.
Connecting a custom domain requires a few configuration steps. You need to add the domain to your Pages project, configure the appropriate DNS settings, and verify that the domain and HTTPS certificate are working correctly.
The exact process depends on whether you want to connect a root domain, such as example.com, or a subdomain, such as www.example.com.
This guide explains both approaches, how to avoid common DNS mistakes, and how to troubleshoot problems if your website does not load after the change.
What Is a Custom Domain?
A custom domain is a website address that you register and control through a domain registrar.
For example, a project hosted on Cloudflare Pages might initially use an address such as:
myproject.pages.dev
After connecting a custom domain, visitors could instead use:
example.com
or:
www.example.com
A custom domain provides a consistent address for sharing your website, publishing a portfolio, or building a recognizable online presence. It does not automatically improve search rankings, but it gives you more control over your public website address.
What You Need Before Starting
Before connecting your domain, make sure you have the following:
- A Cloudflare account.
- An existing Cloudflare Pages project with a successful deployment.
- A registered domain name.
- Access to the domain’s DNS settings or nameserver settings.
- Access to the email account associated with your domain registrar.
You should also understand where your email is hosted. If your domain already receives email, changing nameservers without preserving the relevant DNS records can interrupt email delivery.
Understand the two domain types
Root domain, also called an apex domain: This is the main domain, such as example.com.
Subdomain: This is an address beneath the root domain, such as www.example.com, blog.example.com, or portfolio.example.com.
Cloudflare Pages uses different setup requirements for these two cases. Follow the section that matches your intended address.

Step 1: Open Your Cloudflare Pages Project
- Sign in to your Cloudflare dashboard.
- Open Workers & Pages.
- Select your existing Pages project.
- Open the Custom domains section.
- Select Set up a domain or the equivalent option shown in your dashboard.
- Enter the domain you want to connect.
For example, enter example.com if you want the root domain, or www.example.com if you want the www subdomain.
Follow the on-screen instructions to continue.
Official documentation: Cloudflare Pages custom domains.
Step 2: Connect a Root Domain
If you want visitors to access your website through example.com, Cloudflare requires the domain to be configured as a Cloudflare zone, with its nameservers pointing to Cloudflare.
Add the domain to Cloudflare
If your domain is not already added to your Cloudflare account, follow the dashboard instructions to add it.
Cloudflare will provide the nameservers assigned to your domain.
Update the nameservers at your registrar
- Sign in to the website where you registered the domain.
- Open the domain’s nameserver settings.
- Replace the existing nameservers with the exact nameservers provided by Cloudflare.
- Save the changes.
The nameserver settings are usually found in your registrar’s domain management area, although the menu names vary between providers.
Important: Before replacing nameservers, review your existing DNS records. Preserve the records required by your email provider and other active services, including MX, TXT, and any relevant verification records. Recreate or verify these records in Cloudflare’s DNS dashboard before relying on the new configuration.
Nameserver changes can take time to propagate. Wait for Cloudflare to recognize the updated configuration before continuing if the dashboard indicates that the domain is not active.
Finish adding the root domain to Pages
Return to your Pages project and complete the custom-domain setup.
Cloudflare can then configure the relevant DNS record for the Pages project when the domain and zone are correctly configured.
Do not copy arbitrary IP addresses from another tutorial. Use the setup generated for your own domain and project.
Step 3: Connect a Subdomain
If you want to use an address such as www.example.com or portfolio.example.com, you can configure a CNAME record.
For this method, you do not necessarily need to move the entire domain’s nameservers to Cloudflare. You can keep your existing DNS provider if it supports the required record and configuration.
Add the subdomain in Pages first
Open your Cloudflare Pages project and go to Custom domains.
Add the subdomain you want to use, such as www.example.com, and follow the setup instructions.
This step matters because manually creating a CNAME record without first associating the custom domain with the Pages project can cause the domain to fail to resolve correctly.
Create the CNAME record
At your DNS provider, create the record using the target shown for your Pages project.
For example, if your project address is myproject.pages.dev, the record may look like this:
| Setting | Example value |
|---|---|
| Type | CNAME |
| Name | www |
| Target | myproject.pages.dev |
| TTL | Automatic or provider default |
The example assumes that www.example.com is the address you want to connect. If you use another subdomain, enter its correct host name.
Do not enter the example project address unless it matches your actual Pages project. Follow Cloudflare’s dashboard instructions if it provides different values.
Verify the DNS configuration
Return to the Pages dashboard and check the custom-domain status.
If the record is correct and the domain has been configured properly, Cloudflare can complete the domain activation process.
Official documentation: Custom domains for Cloudflare Pages.
Step 4: Enable and Test HTTPS
HTTPS encrypts the connection between the visitor’s browser and the website. It helps protect data in transit and allows visitors to access your website through an encrypted connection.
Cloudflare Pages supports HTTPS for configured custom domains, subject to successful domain verification and certificate provisioning.
After adding the domain:
- Open your Pages project.
- Check the custom-domain status.
- Wait for the domain and certificate configuration to complete.
- Visit your website using
https://. - Confirm that the browser does not display a certificate warning.
If HTTPS is not active immediately, check the domain status and follow Cloudflare’s troubleshooting guidance before making additional DNS changes.
If you have restrictive CAA records, they may affect certificate issuance. Check your existing DNS configuration if Cloudflare reports a certificate problem.
Official guide: Cloudflare Pages custom domains.
Step 5: Test Your Website
Once the domain is active, test the website from a browser.
Check the following:
- The intended domain opens your Pages project.
- The homepage displays correctly.
- CSS styles and JavaScript files load.
- Images, fonts, and other assets appear correctly.
- Internal navigation works.
- HTTPS works without certificate warnings.
- The website displays properly on mobile devices.
If your project uses a framework, confirm that its build output and asset paths are configured correctly. A domain connection does not fix errors in the website’s code or build process.
You can also test the default pages.dev address to help distinguish a deployment problem from a custom-domain problem.
Step 6: Decide What to Do With the pages.dev Address
Cloudflare Pages provides a default pages.dev address for a project. After connecting a custom domain, you may choose to keep using that address for testing or configure a redirect to your preferred domain.
For example, you might want visitors to use https://example.com instead of the default project address.
Cloudflare documents a process for redirecting the default pages.dev address to a custom domain using Bulk Redirects.
Before configuring redirects, confirm that your custom domain is active and working. Test the redirect afterward to ensure that it points to the correct destination.
Official guide: Redirecting a pages.dev address to a custom domain.
Common Problems and How to Fix Them
The domain does not resolve
Check that you entered the correct domain and configured the DNS record or nameservers as instructed.
If you changed nameservers, verify that Cloudflare recognizes the updated configuration. If you connected a subdomain, check the CNAME target.
Allow time for DNS changes to become visible before repeatedly changing records.
Cloudflare shows a domain configuration error
Confirm that you added the domain through the Pages dashboard. For a subdomain, creating a CNAME record alone is not sufficient if the domain has not been associated with the Pages project.
Review the custom-domain status and follow the specific error message shown in your dashboard.
The website displays a 522 error
A 522 error can have several causes, and it should not automatically be treated as a generic DNS propagation problem.
If you are using Cloudflare Pages, verify that the custom domain is associated with the correct project and that the DNS configuration matches Cloudflare’s instructions. Check the domain status and review the provider’s troubleshooting guidance.
Avoid adding arbitrary A records or changing DNS values without understanding the reason for the error.
HTTPS is not working
Check whether the custom domain has completed activation and whether its certificate is ready.
Review any CAA records that may restrict certificate issuance. Make sure you are using the intended HTTPS address and that the domain has not been redirected to an incorrectly configured destination.
Email stopped working after changing nameservers
Review the DNS records for your email provider. Confirm that the correct MX records and any required SPF, DKIM, DMARC, and verification TXT records exist in the active DNS zone.
Do not delete email records simply because you are connecting a website to Cloudflare Pages. Website hosting and email hosting can be separate services.

Frequently Asked Questions
Can I connect a custom domain to Cloudflare Pages for free?
Cloudflare Pages supports custom domains, but you still need to own or register the domain unless it was provided to you through another offer. Check current service terms and any domain registration costs.
Do I need to transfer my domain to Cloudflare?
Not necessarily. A root domain connected to Pages requires the relevant zone to use Cloudflare nameservers. A subdomain can be configured through a CNAME at an existing DNS provider, subject to Cloudflare’s requirements.
Changing nameservers is different from transferring domain registration to another registrar.
Can I use www.example.com instead of example.com?
Yes, provided you configure the intended subdomain through the Pages dashboard and set up the required DNS record. If you want both addresses to work, configure the additional domain and redirect behavior as needed.
Will connecting a custom domain improve my Google rankings?
A custom domain does not guarantee higher rankings. It can provide a consistent address for your website, but search visibility depends on many factors, including useful content, accessibility, technical quality, and relevance.
Do I need to change my nameservers for a subdomain?
Not always. A subdomain can be connected through a CNAME record at an existing DNS provider if the required configuration is supported. A root domain has different requirements and must be configured as a Cloudflare zone for Cloudflare Pages.
How long does it take for a custom domain to work?
It depends on the DNS configuration, nameserver changes, verification, and certificate provisioning. Follow the status shown in Cloudflare’s dashboard rather than relying on a fixed completion time.
Conclusion
Connecting a custom domain to Cloudflare Pages is straightforward when you follow the correct process for your domain type.
For a root domain, configure the domain as a Cloudflare zone and point its nameservers to Cloudflare. For a subdomain, add it to your Pages project and configure the required CNAME record at your DNS provider.
Preserve existing email records, verify the domain status, and test HTTPS and website functionality before considering the setup complete.
If a problem occurs, check the specific domain status and DNS configuration instead of making unrelated record changes. This approach makes troubleshooting easier and helps keep your website and other domain services working correctly.
No Comment! Be the first one.