HostleloBlog
SavedSearch
Visit Hostlelo

Connect your domain to hosting: DNS records or nameservers?

Point a domain at your hosting step by step at Namecheap, GoDaddy, Cloudflare or cPanel, keep email working, and prove it with dig before you cancel anything.

The short answer

To connect a domain to hosting, either keep your current DNS provider and set an A record for the bare domain plus a www record pointing at your server, or change the domain's nameservers to your host's. Pointing records is safer when email or other services already use the domain. Before changing nameservers, rebuild every record at the new provider, especially MX, SPF, DKIM, DMARC and verification records, and turn off DNSSEC at the registrar first. Check the result with dig, and keep the old hosting running until caches expire.

A grid globe connects through a routing node to a website window and hosting server.
Reading options

On this page

There are two ways to connect a domain to your hosting. You can keep your current DNS provider and point a couple of records at the new server (an A record for the bare domain and a CNAME or A record for www), or you can change the domain's nameservers so your hosting provider runs all of its DNS. Both work. The difference is what happens to everything else attached to the domain, especially email.

Here is the mistake this guide is built to prevent (a made-up example). Omar buys omarstudio.example at one company and hosting at another. The hosting welcome email says "change your nameservers to these", so he does. An hour later the new website is live and he is delighted. The next morning a client calls: "I emailed you three times." His Google Workspace mail had stopped arriving, because its records lived at the old DNS provider and never made the move.

By the end of this guide you will know which method fits your situation, how to do it step by step at Namecheap, GoDaddy, Cloudflare or in cPanel, how to protect your email while you do it, and how to prove it worked with a few commands.

What connecting a domain actually involves

Three different jobs are involved, and they are often done by three different companies:

  • The registrar is where you bought the domain. It holds the registration and one crucial setting: which nameservers are in charge of the domain.
  • The DNS provider runs those nameservers and stores the records, the small entries that say "the website is at this address" or "email goes to this server". Sometimes it is the registrar, sometimes your host, sometimes Cloudflare.
  • The web host is the server that actually stores and serves your website files.

Think of DNS as the reception desk in an office tower. The registrar decides which receptionist works the desk (the nameservers). The receptionist holds the directory (the records). Changing one directory entry sends visitors for one company to a new floor. Changing the receptionist means the new one needs a full copy of the directory, or some visitors get lost.

Records or nameservers: which method should you use?

Pick one method. Doing half of each is how domains end up in a confusing state.

  • Point records (keep your current DNS): best when other things already depend on your DNS, such as business email, Microsoft 365 or Google Workspace verification, a CDN, or subdomains on other services. You only change the website records, and everything else stays exactly where it is.
  • Change nameservers (let the host run DNS): best for a brand-new domain with nothing attached yet, or when you want one place to manage everything. The catch: the new DNS provider starts with only the records you give it, so you must copy everything that matters first.

Changing nameservers replaces the whole directory. Namecheap's own help pages warn that when you switch between their DNS and custom nameservers, host records are not copied to the new nameservers automatically.

Before you start

Gather these before you touch anything:

  • Logins for your registrar, your current DNS provider (if different) and your hosting account.
  • The destination details from your host. For the records method, the server's IPv4 address, plus an IPv6 address only if your host gives you one. For the nameserver method, the exact nameserver names. With Hostlelo, these are in your hosting welcome email or available from support. Never copy nameservers or IP addresses from someone else's guide or an old screenshot.
  • A copy of your current DNS records. Take a screenshot or export of every record, and pay special attention to MX, and to TXT records holding SPF, DKIM, DMARC and service verifications, plus any CAA records.
  • Whether DNSSEC is switched on at your registrar. It matters for the nameserver method.
  • Time and risk. About 15 to 30 minutes of work, then a waiting period while caches update. Low risk if you keep the old hosting and email running until the new setup is confirmed.

Method A: point your records at the new hosting

You stay with your current DNS provider and change only the records that decide where the website lives.

Step 1: Look at what is there now

These commands show the current website and mail records for a domain. On Windows, use nslookup with the same names.

dig +short A example.com
dig +short AAAA example.com
dig +short CNAME www.example.com
dig +short MX example.com

Write the answers down. The MX answer is the one you must not break.

Step 2: Know which records to set

For a typical website you set two things, and leave everything else alone:

  • The bare domain: an A record with the host name @ (which means example.com itself) pointing to your server's IPv4 address, for example 192.0.2.10.
  • The www name: a CNAME record with the host name www pointing to example.com, or an A record for www with the same IP address, whichever your host recommends.
  • IPv6: add or update an AAAA record only if your host gives you an IPv6 address. Delete an old AAAA record that points at your previous host, or some visitors will still land on the old server.
  • Do not touch MX, email-related TXT records, or records for other services.

Heads up: you cannot normally put a CNAME on the bare domain. The original DNS standard, RFC 1034, says that if a CNAME is present at a name, no other data should be there, and the bare domain always carries NS and SOA records. Use an A record for @. Cloudflare offers a workaround called CNAME flattening, which returns the final IP address instead of the CNAME, and some other DNS providers have a similar ALIAS record type.

Step 3a: At Namecheap (BasicDNS)

This works when the domain uses Namecheap BasicDNS, PremiumDNS or FreeDNS.

  1. Sign in and open Domain List, then click Manage next to the domain.
  2. Open the Advanced DNS tab.
  3. In Host Records, edit the existing A record for @, or click Add New Record, choose A Record, enter @ as Host and your server IP as Value.
  4. Do the same for www (as a CNAME to your domain, or an A record).
  5. Remove conflicting records on the same host, such as an old redirect or a second A record, then save with the green check icon.

Namecheap says new records typically take about 30 minutes to become active.

Step 3b: At GoDaddy

  1. Sign in to your GoDaddy Domain Portfolio and select the domain.
  2. Select DNS to view the records.
  3. Edit the existing A record for @, or select Add New Record, choose A as the Type, enter @ as the Name and your server IP as the Value.
  4. Set the www record the same way, then select Save. If Domain Protection is on, GoDaddy asks you to verify your identity first.

GoDaddy's default TTL is 1 hour. Resolvers can keep an old answer for up to the old record's TTL, so a change can take that long to reach everyone.

Step 3c: At Cloudflare

  1. In the Cloudflare dashboard, open your domain and go to DNS > Records.
  2. Edit the A record for your domain name (shown as example.com or @) and set the IPv4 address. Edit or add the www record.
  3. Decide the proxy status. Proxied (orange cloud) routes web traffic through Cloudflare; DNS only (grey cloud) hands out your server's real address.

Quick tip: proxy only website records. Only A, AAAA and CNAME records can be proxied at all, and Cloudflare recommends DNS only for records that do not serve web traffic, such as records used for email routing or third-party domain verification. A mail.example.com record that your mail server uses should stay grey. If you proxy the site, set the SSL mode to Full (strict) once your host has a certificate in place, as our guide on forcing HTTPS without redirect loops explains.

Step 3d: In cPanel's Zone Editor (when cPanel runs your DNS)

If your domain already uses your hosting's nameservers, the records live in cPanel.

  1. Open cPanel > Domains > Zone Editor.
  2. Click Manage next to the domain.
  3. Click Edit next to the A record for the domain, or click Add Record (the arrow next to it lets you pick the record type).
  4. Click Save Record, then check the result with dig as in the verification section below.

Zone Editor only changes the live internet if your domain's nameservers actually point to this server. If they point somewhere else, edit the records there instead.

Method B: change the nameservers

You hand the whole DNS zone to your hosting provider (or to a DNS service like Cloudflare).

Step 1: Get the exact nameserver names

Use the nameservers from your own hosting account, exactly as written, usually two or more names such as ns1. and ns2. something. For Hostlelo, check your hosting welcome email or your service details in the client area, or ask support to confirm them, and see our nameserver change checklist for the Hostlelo side. A single wrong letter makes the whole domain stop resolving.

Step 2: Rebuild the zone at the new DNS provider first

Before you change anything at the registrar, make sure the new DNS provider already has every record you need:

  • The website records (A, AAAA if used, www).
  • MX records for your email provider.
  • TXT records for SPF, DKIM and DMARC. Our SPF, DKIM and DMARC guide shows what they look like.
  • Verification TXT or CNAME records for services like Google Workspace, Microsoft 365, or search consoles.
  • Any subdomains that point to other services, and any CAA records.

On cPanel hosting, check the zone in Domains > Zone Editor after the account is created. If you are moving to Cloudflare, its setup can scan your existing records and import them, but you still need to compare the list with your screenshot, especially the email records.

Step 3: Handle DNSSEC before the switch

If DNSSEC is active at your registrar, turn it off before you replace the nameservers, then wait for the old DS record's cache time to pass. Cloudflare's setup guide warns that skipping this "can cause your domain to become unreachable". Once the new nameservers are working, you can switch DNSSEC on again at the new provider and publish its new DS record at the registrar.

Step 4a: Change nameservers at Namecheap

  1. Open Domain List and click Manage next to the domain.
  2. Find the Nameservers section and choose Custom DNS from the drop-down.
  3. Enter each nameserver in the ns1.example.tld format, then click the green check mark to save.

Namecheap says it may take up to 24 hours (more in rare cases) for internet providers to update their caches.

Step 4b: Change nameservers at GoDaddy

  1. In Domain Portfolio, select the domain.
  2. Select DNS, then Nameservers.
  3. Choose I'll use my own nameservers, enter the names, then select Save and Continue. If Domain Protection is on, GoDaddy asks you to verify your identity.

GoDaddy says most DNS changes take effect within an hour, but can take up to 48 hours to update globally.

Step 5: Leave the old services running while you wait

Keep your old hosting and old DNS zone active for at least a couple of days. Visitors whose resolvers still remember the old answers will keep reaching the old setup until their caches expire. Cancelling too early is how sites go blank for some visitors and not others.

Do not forget the hosting side

Pointing DNS at a server is half the job. The server also needs to know your domain exists and which folder to serve, or it shows a default "domain not configured" page. On cPanel hosting, the domain must be the account's main domain or be added under Domains. On a VPS, you need a matching virtual host or server block.

Then sort out HTTPS. Most hosts issue a free certificate automatically once the domain points at them, which can take a little while after DNS updates. When the padlock appears for both example.com and www.example.com, set up the redirect from our HTTP to HTTPS guide.

How to check it worked

Check what the internet sees, because your browser and computer cache DNS answers and can show you an old picture.

These commands show the nameservers in charge, the website address, and the mail servers:

dig +short NS example.com
dig +short A example.com
dig +short A www.example.com
dig +short MX example.com

You want the NS answer to show your intended nameservers, the A answers to show your new server IP, and the MX answer to show your email provider, unchanged.

To ask the authoritative nameserver directly, skipping every cache, put its name after an @. Replace the example name with your real nameserver:

dig +short A example.com @ns1.your-dns-provider.example

If that shows the new IP but a plain dig does not yet, your setup is correct and you are only waiting for caches to expire. Cloudflare's own setup guide suggests the same kind of check, dig ns example.com @1.1.1.1, and online checkers such as whatsmydns.net show what resolvers around the world currently return. Finally, check the web server itself answers for your domain:

curl -I http://example.com/

Troubleshooting

A default hosting page or "domain not configured" appears

DNS is working, but the server does not know about the domain. Add it to your hosting account (main domain or addon domain) or create the virtual host, then reload.

The old website still appears

Your computer, your router or your internet provider is still using a cached answer. Test with dig against a public resolver, for example dig +short A example.com @1.1.1.1, try mobile data, and check for an old AAAA record pointing at the previous host. Also check your computer's hosts file in case you added a test entry and forgot it.

Email stopped arriving after the change

The new DNS zone is missing your MX records or email TXT records. Add them back exactly as your email provider specifies, using the screenshot you took before you started.

www works but the bare domain does not (or the other way round)

One of the two records is missing or points somewhere else. Make sure both @ and www are set, and remember that the bare domain needs an A record, not a CNAME, unless your DNS provider offers flattening.

The browser says DNS_PROBE_FINISHED_NXDOMAIN

Resolvers cannot find the domain at all. Check the nameserver names for typos, confirm that the new DNS provider actually has a zone for the domain, and confirm in your registrar account that the domain has not expired.

A certificate warning appears after the move

The new host has not issued a certificate for the domain yet, or issued it for only one of example.com and www.example.com. Give automatic issuance some time after DNS updates, then ask your host to reissue it covering both names.

The site works on Wi-Fi but not on mobile data (or vice versa)

Different networks use different resolvers with different cache timing. If the authoritative check above already shows the right answer, wait out the TTL. If it does not, fix the record at the DNS provider.

The one message worth forwarding

Send this to your hosting support or developer before you change anything:

"We want to connect example.com to our new hosting. Our email runs on another provider. Can you confirm whether we should update only the A and www records, or change nameservers? If we change nameservers, please make sure the new zone has our MX, SPF, DKIM, DMARC and verification records before we switch, and tell us the exact nameserver names and the server IP."

The takeaway: point records when other services depend on your DNS, change nameservers only after the new zone is complete, and keep the old services running until dig agrees with you.

Reader questions

Should I change nameservers or just update the A record?

Update the A and www records if email or other services already use your domain, because only the website moves. Change nameservers when the domain is new or you want your host to manage all DNS, after copying every record you need to the new provider.

How long does a nameserver change take?

Namecheap says up to 24 hours, more in rare cases. GoDaddy says most changes take effect within an hour but can take up to 48 hours to update globally. Individual records often update faster, depending on their TTL.

Will changing nameservers break my email?

It can. The new DNS provider only has the records you give it, so add your MX, SPF, DKIM, DMARC and verification records there before you switch the nameservers at the registrar.

Can I use a CNAME record for my bare domain?

Normally no. RFC 1034 says no other data should sit at a name that has a CNAME, and the bare domain always has NS and SOA records. Use an A record, or a flattening or ALIAS feature if your DNS provider offers one.

Why do I still see my old website after changing DNS?

Your computer, router or internet provider is using a cached answer. Check with dig against a public resolver or the authoritative nameserver, try another network, and delete any old AAAA record that points at the previous host.

Do I need to turn off DNSSEC before changing nameservers?

Yes, if it is active. Cloudflare warns that changing nameservers while DNSSEC is active can make the domain unreachable. Disable it at the registrar first, then re-enable it with the new provider's DS record once the switch is done.

Should email records be proxied through Cloudflare?

No. Only A, AAAA and CNAME records can be proxied, and Cloudflare recommends DNS only for records that do not serve web traffic, such as those used for email routing or domain verification.

Sources & further reading

  1. Namecheap: How to change DNS for a domain
  2. Namecheap: How to set up an A record
  3. GoDaddy: Change my domain nameservers
  4. GoDaddy: Add an A record
  5. Cloudflare: Full DNS setup
  6. Cloudflare: Proxy status
  7. Cloudflare: CNAME flattening
  8. cPanel documentation: Zone Editor
  9. RFC 1034: Domain names, concepts and facilities

Originally published . About our editorial updates.

Your next project deserves a better foundation.

Explore hosting built for your next chapter.

Explore hosting

Find your next answer.

Search published guides and articles.

Ctrl / ⌘ K to open · Esc to close