Back to blog

How to Connect a Domain to Hosting: Nameservers or A Record

IM Host EditorialOctober 10, 20268 min read
How to Connect a Domain to Hosting: Nameservers or A Record

There are two ways to connect a domain to hosting. You either change the domain's nameservers to the ones your host gives you, so the host manages all DNS, or you keep DNS where it is and point an A record (plus www) to the hosting server's IP address. Nameservers are simplest for a new domain. Editing records is safer when email or other services already run on the domain.

Below are both methods step by step, how long the change takes to spread, how to check it yourself with dig and nslookup, and the mistakes that cause most "my domain doesn't open" tickets.

Before you start: three things to have ready

  • Access to the registrar account where the domain is registered. Connecting a domain does not require moving it.

  • Your hosting details: either the two (or more) nameservers from your welcome email, or the server IP address. In cPanel the IP is shown in the General Information panel on the right.

  • The domain added on the hosting side. If it is not the main domain of the account, add it in cPanel under Domains first. Otherwise the server receives visitors but does not know which site to show.

Method 1: Change the nameservers

Nameservers decide who answers DNS questions for your domain. When you switch them to your host's, every record (website, email, verification) is then managed in the hosting DNS zone.

Use it when: the domain is new or unused, email will run on the same hosting, and you want one place to manage everything.

  1. Log in to your registrar and open the domain's Nameservers or DNS settings.

  2. Choose the custom nameservers option and replace the existing entries with the ones your host gave you, for example ns1.example.net and ns2.example.net. Enter them exactly, without http:// or spaces.

  3. Remove any extra old nameservers. Mixing nameservers from two providers gives random answers.

  4. If DNSSEC is enabled at the registrar, turn it off (remove the DS record) before the switch, unless your new DNS provider signs the zone and gives you a new DS record. A leftover DS record makes the domain fail to resolve.

  5. Save, then check the result with the commands below.

Important: records at the old DNS provider are not copied over. If the domain already had email, a Google verification TXT, or subdomains, recreate them in the new zone before you switch.

Method 2: Keep your DNS and edit the A and CNAME records

Here you leave the nameservers alone and change only the records the website needs. Everything else in the zone stays as it is.

Use it when: email already works on the domain (for example with a separate email provider), DNS is managed at Cloudflare or another service, or you only want to move the website.

  1. Open the DNS zone where your domain is currently managed.

  2. Edit the A record for the root (shown as @ or the bare domain) and set it to your hosting server's IPv4 address.

  3. For www, add a CNAME pointing to example.com, or an A record with the same IP. Use one or the other, not both.

  4. If there is an AAAA record pointing to an old server, delete it or update it with the new server's IPv6 address. Otherwise visitors on IPv6 networks keep reaching the old site.

  5. Leave the MX, SPF, DKIM and other TXT records untouched unless email is also moving.

A typical result looks like this:

example.com.      3600  IN  A      203.0.113.10
www.example.com.  3600  IN  CNAME  example.com.
example.com.      3600  IN  MX     10 mail.example.com.

Replace example.com with your domain and 203.0.113.10 with your server IP. If record types like CNAME, MX and TXT are still unclear, our guide to DNS records explained covers each one with examples and the mistakes to avoid.

How long DNS propagation takes

"Propagation" is really caching. Resolvers around the world keep the old answer until its TTL (time to live) runs out, then ask again.

  • A or CNAME change: visible to most visitors within the record's old TTL. With a TTL of 3600 seconds, expect up to about an hour.

  • Nameserver change: slower, because the delegation is cached at the TLD level. For .com that cache can last up to 48 hours, although many resolvers pick up the change within a few hours.

  • Rule of thumb: if you plan a move, lower the TTL to 300 seconds a day before. Then the actual switch reaches nearly everyone within minutes.

For a move where downtime and lost email are not acceptable, follow the sequence in our zero-downtime DNS and email migration guide.

How to check that the domain points to your hosting

On Linux or macOS use dig. On Ubuntu or Debian, install it with:

sudo apt update && sudo apt install dnsutils

Then run these, replacing example.com with your domain:

# Which nameservers are in charge?
dig +short NS example.com

# What IP does the domain point to?
dig +short A example.com
dig +short www.example.com

# Ask a public resolver directly, bypassing your local cache
dig +short A example.com @1.1.1.1
dig +short A example.com @8.8.8.8

# Where does email go?
dig +short MX example.com

On Windows, nslookup does the same job:

nslookup -type=NS example.com
nslookup example.com 8.8.8.8
nslookup -type=MX example.com

Online DNS checkers that query servers in many countries are also useful to see whether some regions still get the old answer.

You can also test the site on the new server before DNS changes at all. This command connects to the new IP while still sending your domain name, so the server serves the right site:

curl -I --resolve example.com:443:203.0.113.10 https://example.com

If your own computer keeps showing the old site after the public resolvers show the new IP, clear the local cache: ipconfig /flushdns on Windows, sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder on macOS, or resolvectl flush-caches on Ubuntu.

Email (MX) gotchas

  • Switching nameservers drops your MX records if you did not recreate them in the new zone. Mail then bounces or goes to the wrong server. Copy MX, SPF, DKIM and DMARC first.

  • Email on hosting: the MX usually points to mail.example.com or to the domain itself. If you move the website but keep email elsewhere, make sure mail does not end up pointing at the new web server.

  • One SPF record only. If you add a second v=spf1 TXT record while connecting a new service, SPF fails. Merge them into one.

  • Old mailboxes: after an MX change, a few messages can still arrive at the old server for up to the TTL period. Check it for a day before closing the old account.

Common errors and how to fix them

  • The domain shows a registrar parking page: nameservers are still the registrar's defaults, or the A record still points to the parking IP.

  • "Default web page" or the wrong site appears: DNS is correct but the domain is not added to the hosting account. Add it in cPanel.

  • Certificate warning after connecting: the free SSL is issued only after DNS points to the server. Wait a short while or ask support to run the SSL check again.

  • Some people see the new site, others the old one: normal during the TTL window. A forgotten AAAA record can make it permanent for IPv6 users.

  • The domain does not resolve at all: check for a leftover DNSSEC DS record, typos in the nameservers, or a suspended domain. Registrars suspend new gTLD domains if the owner email is not verified within a set period, so look for that verification email.

  • "CNAME at the root" is rejected: the root of a domain cannot be a normal CNAME alongside other records. Use an A record for @.

Connecting is not the same as transferring

Connecting points the domain at your hosting. Transferring moves the domain registration itself to a different registrar, using an authorization (EPP) code, and usually adds a year to the registration. You can host anywhere while the domain stays at its current registrar. If you prefer to manage domain and hosting in one account, our domain transfer page explains the process, and our article on choosing a host that makes domain transfers painless lists what to check first.

Frequently asked questions

Should I use nameservers or an A record?

Use nameservers for a fresh domain where everything, including email, will live on the same hosting. Use an A record when email or other services already run on the domain and you do not want to touch them.

Why is my domain not working after changing the nameservers?

Usually it is still cached. Check with dig +short NS example.com @8.8.8.8. If the new nameservers appear but the site does not, the domain probably is not added on the hosting account or the zone has no A record.

How do I find my hosting server's IP address?

It is in your welcome email and in the cPanel General Information panel. On a VPS, run ip -4 addr or check your client area.

Can I connect a domain from one company to hosting at another?

Yes. Either method works across companies. The registrar only needs to know the nameservers or hold the records you set.

If you are registering a new name, IM HOST domains include free DNS management and domain lock, and activate right after payment. Our engineers can set up the nameservers or records for you at any hour, if you would rather not do it yourself.

More from our blog

Discover more practical guides and product insights from the IM Host team.

View all articles