You've created a subdomain, you type blog.example.com into the browser, and instead of the site you get the "This site can't be reached" page or the DNS_PROBE_FINISHED_NXDOMAIN error. Or worse: the site loads but the browser shows a certificate warning saying the name on the certificate doesn't match the domain. Both problems almost always come back to a single point: the record you've registered doesn't match what the destination server expects. This article unpacks exactly that decision.
A Record or CNAME; Which One to Choose for Creating a Subdomain
The first question is always this: should I point the subdomain to an IP or to a name?
If the destination server has a static IP and you control it yourself, use an A record. It's simple, has one less layer of translation, and in the server logs you see exactly which client came from where. Its syntax in the DNS panel looks like this:
blog.example.com. 3600 IN A 185.xx.xx.xx
If the destination is a cloud service that changes your IP (shared hosting, CDN, hosting platform), use a CNAME. A CNAME means "whatever that name points to, I say the same" and when the provider changes the IP, you don't have to touch DNS:
shop.example.com. 3600 IN CNAME target.provider.net.
A technical point that trips up many people: a CNAME is not allowed at the domain root (for example example.com without a subdomain), because it conflicts with SOA and NS records. For the root you must use an A or ALIAS/ANAME record. For a subdomain, however, a CNAME is completely safe.
| Criterion | A Record | CNAME Record |
|---|---|---|
| Destination value | Static IP | Domain name |
| Server IP change | You must change it manually | Follows automatically |
| At the domain root | Allowed | Not allowed |
| Extra cost | One less lookup | One more resolve step |
My choice in practice: as long as the server is under your control, use an A record; the moment the destination goes out of your control, use a CNAME. If you're unsure, choose the CNAME, because the cost of getting it wrong is lower.
Subdomain on Another Server: From DNS to the HTTP Response
Registering the record is only half the work. The destination server must also know it's hosting this name. If you point the A record to the new server's IP but no VirtualHost or server block is defined for blog.example.com on that server, depending on the configuration you'll see one of these: the server's default page, a 404 error, or the main site that's on the same IP.
In Nginx, create a separate file:
server {
listen 80;
server_name blog.example.com;
root /var/www/blog;
index index.html;
}
In Apache, the equivalent is ServerName blog.example.com inside a <VirtualHost>. After the change, always run nginx -t or apachectl configtest and then reload. A typo in server_name causes requests to fall through to the first VirtualHost and you'll think DNS is broken.
To find out whether DNS is resolving correctly, test from the terminal before touching the browser:
dig +short blog.example.com A
dig +short blog.example.com CNAME
curl -I -H "Host: blog.example.com" http://185.xx.xx.xx
The last command is important: with -H "Host:" you call the IP directly and send the Host header manually. If the response is correct here but not in the browser, the problem is definitely DNS or caching, not the web server. If it's the opposite, the problem is in the VirtualHost. This separation eliminates half the troubleshooting time.
SSL Certificate for a Subdomain; Where the Most Mistakes Happen
An SSL certificate on the main domain does nothing for a subdomain, unless it was explicitly issued for it. You have three options:
- A separate certificate for each subdomain: with Certbot this is the simplest way;
certbot --nginx -d blog.example.com. Each subdomain has an independent certificate and each one's expiration is managed separately. - wildcard: a single certificate for
*.example.comthat covers all subdomains one level deep. It requires DNS-01 validation, not HTTP-01. - multi-domain (SAN): a single certificate with several specific names. Suitable when the number of subdomains is fixed and small.
Here's where people make a mistake: they get a wildcard certificate and feel relieved, then they create a.b.example.com and get a certificate warning. A wildcard only covers one level; *.example.com does not include a.b.example.com. The sign is that the domain opens in the browser but the lock is red and in the certificate details, the hostname doesn't match the CN.
Second mistake: they point the CNAME record to a destination that itself has a valid certificate, but since the traffic passes through their own server, the browser sees their own server's certificate. The destination's certificate is never seen on this path at all. If you're using a reverse proxy, you must issue the certificate on that same edge.
For a quick review of the syntax of record types and their limitations, keep the complete reference of DNS record types at hand; when you're lost with a TXT or CAA record, it answers faster than scattered searching.
TTL and Pointless Waiting
You've changed the record and you've been staring at the old page for ten minutes. This is almost always caching, not a failure. Lower the TTL value before making the change; if the TTL is set to 3600 seconds, it means the old version may be served for up to an hour.
The correct method is this: a day earlier, lower the TTL to 300, make the main change, test, then restore the TTL. If you're in a hurry and change the TTL at the same moment, cached records in intermediate resolvers will still be served with the previous value. To understand why this delay is unavoidable, read the guide to DNS propagation and the role of TTL.
To check what the record looks like from the perspective of different name servers, use the DNS record lookup tool. If you get the same answer from several geographic locations, you're done and the problem is elsewhere.
When Subdomains Multiply
If you have dozens of subdomains, some of which are dynamic (for example, one subdomain per customer), manual record registration won't cut it. You have two options: a wildcard record in DNS, or programmatic management through the DNS provider's API. A wildcard record is fast but has one serious drawback: any name under that domain resolves, even names that don't exist, and this makes SSL certificate management and error detection difficult. The details are in wildcard records and managing dynamic subdomains.
If you're moving the subdomain to a separate virtual server, the order of work matters: first the record, then the VirtualHost, then the certificate. If you swap the order of these three, you'll spend your time troubleshooting something that isn't the problem at all. The step-by-step guide for this path is in connecting a domain to a virtual server from A record to SSL.
And if the destination is a shared host that manages the certificate and VirtualHost itself, it's usually enough to add the subdomain from the hosting panel and then point the CNAME record to the name the panel gives you. For light loads and WordPress sites, Linux hosting shortens this path since the certificate and domain configuration are done from the same panel.
The Troubleshooting Order That Actually Works
- Use
dig +shortto check whether the record resolves correctly. - Use
curl -I -H "Host: ..."to hit the IP directly and remove DNS from the equation. - If you got an HTTP response but the certificate had a problem, go for reissuing the certificate, not DNS.
- If you got no response at all, check the firewall and ports 80/443 on the destination server.
If you're still stuck after these four steps, go through the DNS troubleshooting guide with symptoms and the order of checking records step by step. Most of the time the problem reveals itself at step two.
Frequently Asked Questions
Do I need to register a new domain to create a subdomain?
No. A subdomain is part of the same registered domain and has no separate registration cost. You just add a record to the DNS zone of that same domain. If you want to register a domain for the first time, start with domain search and registration and then create subdomains on it.
Why doesn't my subdomain open but the main domain is fine?
Because the subdomain's record either isn't registered or points to the wrong destination. Use dig +short sub.example.com to see what IP comes back and compare it with the destination server's actual IP. If it comes back empty, the record doesn't exist or was registered in the wrong DNS zone.
Does the main domain's SSL certificate also work for the subdomain?
No, unless the certificate explicitly includes that name. A regular certificate is only valid for the names listed in it. To cover subdomains you must get a separate certificate, a multi-domain certificate, or a wildcard.
How long does it take for a new subdomain to become active?
Usually a few minutes to a few hours, depending on the record's TTL and resolver caches. If the TTL is set to 300 seconds, the change is seen almost immediately; if it's set to 86400, it may take up to a day.