How to Change DNS Records for Hosting
In this article
Changing DNS records is how you point your domain name to a new hosting provider, set up email services, or add subdomains. This guide walks you through editing A, CNAME, MX, and TXT records at your domain registrar or DNS provider, so your website resolves to the correct server.
What You'll Need
- Access to your domain registrar or DNS hosting account (e.g., GoDaddy, Namecheap, Cloudflare, or your web host).
- The DNS records provided by your new hosting company (usually an IP address for the A record, or a hostname like
example.comfor CNAME). - Your domain name (e.g.,
example.com). - If you're moving email, have the MX record details from your email provider.
Step-by-Step
- Log in to your DNS provider. Go to the website where your domain's DNS is managed. This is often the same place you bought the domain, but it could be a separate service like Cloudflare. Look for a section called "DNS," "DNS Management," "Name Servers," or "Advanced DNS."
- Find the DNS records page. Once logged in, select your domain name from a list if you have multiple. Then click on the DNS settings or records tab. You'll see a table of existing records.
- Identify the record you need to change. Common record types:
- A record – points a hostname (like
@orwww) to an IPv4 address (e.g.,192.0.2.1). - AAAA record – points to an IPv6 address.
- CNAME record – points a hostname to another hostname (e.g.,
wwwtoexample.com). - MX record – directs email to a mail server.
- TXT record – holds text data, often for verification (SPF, DKIM).
- A record – points a hostname (like
- Edit the existing record. Click the edit/pencil icon next to the record you want to change. For an A record, you'll typically change the "Points to" or "Value" field to the new IP address. For a CNAME, change the "Target" or "Value" to the new hostname. Leave the "TTL" (Time to Live) at its default unless you have a reason to change it.
- Save the change. Click the "Save" or "Update" button. Some providers ask you to confirm the change – do so.
- Add a new record if needed. If the record doesn't exist yet (e.g., you're adding a subdomain like
blog.example.com), click "Add Record" or "Create New Record." Choose the type, fill in the host/name and value, then save. - Verify the change. After saving, use a tool like
digor an online DNS checker to see if the record has updated. Note that DNS propagation can take from a few minutes to 48 hours, but often it's faster.
Common Mistakes
- Editing the wrong domain. If you manage multiple domains, double-check you're on the correct one before making changes.
- Using the wrong record type. For example, using a CNAME for the root domain (
@) when you need an A record. Many providers won't allow a CNAME at the root. - Forgetting the trailing dot. Some DNS providers require a trailing period (.) at the end of a hostname value, like
example.com.Check your provider's format. - Changing MX records when you only meant to change web hosting. This can break email. Only touch MX records if you're moving email.
- Setting TTL too low. A very low TTL (like 30 seconds) causes more DNS queries, but it's fine for testing. A high TTL (like 86400) means changes take longer to propagate.
Tips
- Lower the TTL before making changes. If you plan to make multiple changes, set the TTL to 300 (5 minutes) a day in advance. This makes updates propagate faster.
- Keep a backup. Before editing, screenshot or copy the existing records. If something breaks, you can restore them.
- Use the provider's documentation. Each DNS provider has a slightly different interface.
- Test after propagation. Use a site like
whatsmydns.netto see if the record has updated globally. - If you're moving hosting, update the A record for both
@andwww. Many people forget thewwwrecord, causing the site to work withoutwwwbut not with it.
Troubleshooting
If your website doesn't resolve after changing DNS records, try these steps:
- Wait longer. DNS propagation can take up to 48 hours, though it's often quicker. Check back after a few hours.
- Clear your local DNS cache. On Windows, run
ipconfig /flushdnsin Command Prompt. On macOS, runsudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderin Terminal. - Check the record value. Make sure you copied the IP address or hostname correctly. A single typo will break the connection.
- Verify the record at the correct location. Use
dig example.com A(ordig @8.8.8.8to query Google's DNS) to see what the authoritative server returns. - Check if your host requires a specific A record. Some hosting providers give you an IP address that changes; they might recommend using a CNAME to a hostname like
example.com.somehost.netinstead. - Ensure your domain isn't locked. If your domain is locked at the registrar, it won't propagate changes. Unlock it temporarily if needed.
- Contact support. If you've waited and the record looks correct, contact your DNS provider or hosting provider for help.
Frequently Asked Questions
How long does DNS propagation take?
It can take from a few minutes up to 48 hours, but most changes propagate within a few hours. The TTL set on the old records affects how long it takes.
What's the difference between an A record and a CNAME?
An A record points a hostname to an IP address directly. A CNAME points a hostname to another hostname, which then resolves to an IP. CNAMEs are useful for aliases like www.
Can I have both a CNAME and an A record for the same hostname?
No, for a given hostname, you can only have one record type that resolves to a target. You can have both an A and a CNAME for different hostnames (like @ and www).
Do I need to change my nameservers instead?
If your DNS records are managed at your registrar, you edit them there. If you want to use a third-party DNS service, you change the nameservers at the registrar to point to that service, then manage records there.
Will changing DNS records affect my email?
Only if you change MX records or TXT records related to email authentication (SPF, DKIM, DMARC). Changing A records for web hosting won't affect email unless your email is hosted on the same server.
What does TTL mean?
TTL (Time to Live) is how long a DNS resolver caches the record before asking again. A lower TTL means changes propagate faster, but it increases DNS query load.