Connecting a domain to hosting means telling the internet which server should answer when someone types your address. The work is done in DNS, and it is usually a matter of changing two or three records. This tutorial shows both common methods, how to check the result, and how to avoid the most expensive mistake: breaking your email.
Before you start
You need three things.
- Access to the domain registrar, the company where the domain is registered and renewed.
- Access to the hosting account the website will live on.
- Knowledge of where your email is handled. If mailboxes on this domain are already in use, write down which provider runs them.
If the difference between these services is unclear, read Domain, DNS and Hosting: What Each Service Does first.
Step 1: Get the connection details from your host
Your hosting account lists one or both of the following, usually on the account overview page or in the welcome email.
- Nameservers, typically two to four names such as ns1.yourhost.example.
- The server IP address, an IPv4 address made of four numbers, and sometimes an IPv6 address as well.
Step 2: Choose a method
Method A: Change the nameservers
You replace the nameservers at the registrar with the ones from your host. From then on, all DNS records for the domain are managed in the hosting account.
Choose this when the domain is new, nothing else uses it yet, and you want the host to configure everything automatically.
Method B: Keep your DNS and change the records
You leave the nameservers alone and edit only the records that point to the website. Everything else, including email, stays exactly as it is.
Choose this when email or other services already run on the domain, or when you prefer to keep DNS with the registrar or a separate DNS provider.
Step 3: Record what exists today
Before changing anything, open the current DNS zone and copy every record into a document or take screenshots. Pay particular attention to MX records and to TXT records that mention SPF, DKIM or DMARC. These control email. If you switch nameservers, any record you do not recreate at the new provider simply stops existing.
Step 4: Make the change
For Method A:
- In the hosting account, add the domain so that a DNS zone is created for it.
- Recreate any existing email records in that zone.
- At the registrar, open the nameserver settings for the domain and replace the old nameservers with the host’s.
- Save. Do not mix old and new nameservers.
For Method B:
- In the hosting account, add the domain so the server knows to answer for it.
- In your DNS zone, edit the A record for the root domain (often shown as @) so it contains the server IP address.
- Point www to the same place, either with a CNAME record that targets the root domain or with a second A record.
- If the host gave you an IPv6 address, add or update the AAAA records too. If it did not, delete any old AAAA records, otherwise some visitors will still be sent to the previous server.
- Leave MX and email-related TXT records untouched.
Step 5: Wait, then check
DNS answers are cached. Each record has a TTL, a time in seconds that tells other servers how long to remember it. Record changes usually appear within minutes to a few hours. Nameserver changes can take longer, occasionally up to a day or two.
To check progress:
- Use an online DNS lookup tool and query the A record for both the root domain and www. Both should return the new IP address.
- Open the site in a private browser window or on mobile data, which avoids your own device’s cache.
- Do not keep changing records while you wait. That restarts the clock and makes problems harder to trace.
Step 6: Finish on the hosting side
- Issue an SSL certificate for the domain in the hosting panel. Most hosts can only do this after DNS points to them.
- Confirm that http:// redirects to https:// and that either www or non-www redirects to the version you chose.
- Send a test email to and from an address on the domain to confirm mail still works.
Troubleshooting
- The old site still appears. Your browser or network is using a cached answer. Test from another network before changing anything.
- Works without www but not with it, or the other way round. One of the two records is missing or points somewhere else.
- Certificate warning. The certificate has not been issued yet, or it does not include both the www and non-www name.
- Email stopped arriving. MX records were lost during a nameserver change. Restore them from the copy you made in Step 3.
- Some visitors see the new site and some the old. Either caches have not expired yet, or an old AAAA record is still present.
Next step
Once the domain resolves and HTTPS works, the server is ready for a website. Continue with How to Install WordPress Safely on a New Hosting Account, and see DNS for Beginners if you want to understand the record types in more depth.
