DNS & Domain Guides

Setting Up Subdomains: DNS Records and Best Practices

Learn how subdomains work, which DNS records to use, how to configure www, app, mail and other subdomains, and how to avoid common setup mistakes.

By CheckDomainHealth Editorial Team Reviewed by Dionis Ceban Updated Jun 28, 2026 7 min read Beginner

Introduction

A subdomain is a separate hostname under your main domain, such as www.example.com, app.example.com, mail.example.com or shop.example.com. Subdomains are commonly used for websites, applications, email services, client portals, documentation, dashboards and third-party platforms.

Setting up a subdomain usually means adding the correct DNS record and making sure the destination service is ready to handle that hostname. DNS can point the subdomain to the right place, but the hosting, CDN, SaaS platform or mail server must also be configured to accept traffic for it.

Quick answer

Quick answer

A subdomain is configured by creating a DNS record for a hostname such as www, app, mail or shop. Use an A or AAAA record when the subdomain should point to an IP address, and use a CNAME when it should point to another hostname provided by a hosting, CDN or SaaS platform.

What is a subdomain?

A subdomain is a hostname that sits before the main domain name.

Examples:

  • www.example.com
  • app.example.com
  • mail.example.com
  • shop.example.com

In these examples, www, app, mail and shop are subdomains of example.com.

A subdomain can point to the same server as the main domain or to a completely different service.

Common subdomain examples

www

Usually used for the public website.

app

Often used for a web application or customer dashboard.

mail

Often used for mail server hostnames or webmail.

shop

Often used for ecommerce platforms.

docs

Often used for documentation or help centers.

panel

Often used for hosting, admin or client portals.

Each subdomain can have its own DNS records and may need separate hosting, SSL and application configuration.

Which DNS record to use

A record

Use when the subdomain should point to an IPv4 address.

app.example.com → 192.0.2.20

AAAA record

Use when the subdomain should point to an IPv6 address.

app.example.com → 2001:db8::20

CNAME record

Use when the subdomain should point to another hostname.

docs.example.com → example.helpcenter.com

MX record

Use only if the subdomain should receive email directly.

mail.example.com can have its own mail routing setup

TXT record

Use for verification or email authentication on a subdomain.

Most website subdomains use either A, AAAA or CNAME records.

Root domain vs subdomain

The root domain is the main domain, such as example.com. A subdomain is a hostname under it, such as app.example.com.

Root domain

  • example.com
  • Usually used for the main website or brand domain

example.com → website IP

Subdomain

  • app.example.com
  • Used for a specific service, section or platform

app.example.com → app server or SaaS target

DNS records for the root domain and subdomains are separate. If example.com works, that does not automatically mean app.example.com or www.example.com works.

Why this matters

Why this matters

Subdomains matter because many services depend on them. A missing or incorrect subdomain record can break www, webmail, apps, shops, portals, documentation, SSL validation or domain verification. The DNS record must point to the correct destination, and the destination service must be configured to recognize the subdomain.

How to check a subdomain

Use DNS Lookup to check the exact subdomain, not only the root domain.

When checking a subdomain, compare

These five areas help confirm DNS and service setup match.

Hostname

The exact subdomain, such as www.example.com or app.example.com.

Current DNS record

Whether the subdomain returns A, AAAA, CNAME, MX or TXT records.

Expected destination

The IP address or hostname required by your hosting, CDN, mail provider or SaaS platform.

Active nameserver

The DNS provider currently controlling the live DNS zone.

Service readiness

Whether the destination platform is configured to serve the subdomain.

Check subdomain DNS now

Use DNS Lookup to inspect records for www, app, mail or any other subdomain.

Run DNS Lookup →

Common problems

Subdomain has no DNS record

High

The subdomain does not resolve because no A, AAAA, CNAME or relevant record exists.

Next step: Add the record required by your hosting, CDN or service provider.

Subdomain points to the wrong server

High

The subdomain points to an old IP address, old hosting account or wrong platform.

Next step: Compare the current DNS value with the provider’s required value.

CNAME target does not resolve

High

The subdomain points to a hostname that does not return valid DNS answers.

Next step: Check the target hostname from your provider and update the CNAME if needed.

www works but root domain does not

Medium

The www subdomain is configured, but the root domain has missing or incorrect records.

Next step: Check both example.com and www.example.com.

Root domain works but www does not

Medium

The main domain points correctly, but the www subdomain is missing or misconfigured.

Next step: Add a CNAME or A record for www based on your provider instructions.

SSL certificate does not include the subdomain

Medium

DNS may be correct, but the SSL certificate may not cover the subdomain.

Next step: Issue or configure SSL for the specific hostname.

Destination platform does not recognize the subdomain

Medium

DNS points correctly, but the hosting, CDN or SaaS platform has not been configured for that hostname.

Next step: Add the subdomain inside the destination platform.

Email subdomain misconfigured

Medium

A mail-related subdomain may need A, MX or TXT records depending on the setup.

Next step: Follow the mail provider’s exact DNS instructions.

How to set up a subdomain

  1. Decide what the subdomain is for

    Confirm whether it is for a website, app, mail service, shop, documentation, CDN or third-party SaaS platform.

  2. Get the required DNS value

    Use the exact IP address or hostname from your provider. Do not guess the value.

  3. Confirm where DNS is hosted

    Check active nameservers and make DNS changes at the provider controlling the live zone.

  4. Add the correct DNS record

    Use A or AAAA for IP addresses. Use CNAME for hostname targets. Use TXT for verification records.

  5. Configure the destination service

    Add the subdomain inside your hosting, CDN, mail or SaaS platform if required.

  6. Check SSL

    Make sure the SSL certificate covers the subdomain before sending users to it.

  7. Verify publicly

    Use DNS Lookup and test the actual URL or service after DNS changes are visible.

Subdomain DNS examples

Record examples
www as CNAME:
www.example.com.   300   IN   CNAME   example.com.

app as A record:
app.example.com.   300   IN   A       192.0.2.20

app with IPv6:
app.example.com.   300   IN   AAAA    2001:db8::20

docs as SaaS CNAME:
docs.example.com.  300   IN   CNAME   example.docsprovider.com.
Check commands
dig www.example.com A
dig www.example.com CNAME
dig app.example.com A
dig docs.example.com CNAME

These are examples only. Replace hostnames, IP addresses and targets with values from your hosting, CDN or SaaS provider.

Subdomains and SSL

Each hostname must be covered by a valid SSL certificate. A certificate for example.com does not always cover app.example.com or shop.example.com.

Common SSL setups:

  • single-name certificate for one hostname
  • SAN certificate covering multiple hostnames
  • wildcard certificate covering many subdomains such as *.example.com
  • CDN or hosting-managed SSL

After adding a subdomain, check SSL before sending users to it.

Subdomains and email

Some subdomains are used for email-related services, such as mail.example.com, smtp.example.com or bounce.example.com.

Depending on the setup, these may need:

  • A or AAAA records
  • MX records
  • SPF TXT records
  • DKIM TXT records
  • DMARC records for subdomains
  • reverse DNS for sending IPs

Only configure email-related subdomains according to your mail provider’s instructions.

Frequently asked questions

What is a subdomain?

A subdomain is a hostname under a main domain, such as app.example.com or www.example.com.

Does a subdomain need its own DNS record?

Yes, if it should resolve publicly. The exact record type depends on where the subdomain should point.

Should www be a CNAME or A record?

Both can work. Many setups use CNAME for www, while others use an A record pointing to the same server IP.

Can a subdomain point to a different server?

Yes. A subdomain can point to a different server, CDN, SaaS platform or mail system than the root domain.

Do subdomains need SSL certificates?

Yes, if they are used over HTTPS. The certificate must cover the exact hostname or a matching wildcard.

Can subdomains have separate email records?

Yes. Subdomains can have separate MX, SPF, DKIM or DMARC records if they send or receive email.

Use these free tools to verify your configuration after applying changes.

Browse all DNS & Domain guides →

Need help applying this fix?

Send us your domain, report link or issue details. CheckDomainHealth will review the request and route it to the right technical team if hands-on support is needed.

Get Help Run Domain Health Check

Was this guide helpful?

Your feedback helps us improve our guides for everyone.