To route subdomains to different servers in Namecheap DNS, add one record per subdomain in Advanced DNS. Use an A record when the server has a fixed IP address, and a CNAME record when a platform gives you a hostname. Your marketing site, API, app and docs can then run on four different hosts, with Namecheap’s free BasicDNS as the only DNS provider.
Quick answer: Each subdomain gets its own record in Namecheap Advanced DNS, pointing at the server or platform that should answer for it.
- Confirm the domain uses Namecheap BasicDNS.
- Add an A record (Host
api, Value the server’s IP) for each server with a fixed IP. - Add a CNAME record (Host
docs, Value the provider’s hostname) for each hosted platform. - Configure the web server on each machine to answer for its subdomain.
- Issue an SSL certificate on each server, then test with
digandcurl.
In this guide
- Before You Start
- How Subdomain Routing Works
- Step 1: Check That the Domain Uses Namecheap DNS
- Step 2: Add an A Record for Each Server
- Step 3: Add a CNAME Record for Each Hosted Platform
- Step 4: Configure the Web Server for the Subdomain
- Step 5: Issue an SSL Certificate on Each Server
- Step 6: Verify Every Subdomain
- If It Still Doesn’t Work
- Frequently Asked Questions
- Next Steps

Before You Start
- Access: your Namecheap login, SSH access with
sudoon each VPS that will serve a subdomain, and the dashboard of each hosted platform (to copy its CNAME target). - Details to collect: the public IPv4 address of every server and the CNAME target of every platform.
- Back up: take a screenshot of your Host Records before editing. If you change an existing subdomain, note its old value so you can switch back.
- Time: about 10 minutes per subdomain for DNS. New records usually resolve within minutes; changed records can take as long as their old TTL.
- Email safety: new A and CNAME records for subdomains do not touch mail. Do not edit MX or TXT records, and never add a CNAME on
@or on a name that already has other records.
How Subdomain Routing Works
The nameservers listed for your domain answer every DNS question about it. With Namecheap BasicDNS, each host record you create can point to a different place. A typical split looks like this:
- Apex domain (
example.com) &www: Main marketing site on shared hosting or WordPress. api.example.com: Node.js, Go, or Python backend running on a dedicated VPS instance.app.example.com: Frontend Single Page Application (SPA) hosted on a CDN or cloud platform.docs.example.com: Static documentation hosted on GitHub Pages or ReadMe.
Use an A record when you have a server’s IPv4 address, and a CNAME record when a platform gives you a hostname to point at. For the example above, the subdomain records in Namecheap look like this:
| Type | Host | Value (example) | TTL | Goes to |
|---|---|---|---|---|
| A Record | api |
198.51.100.42 |
Automatic | Your API server (VPS) |
| CNAME Record | app |
The hostname your app platform shows | Automatic | Cloud or CDN platform |
| CNAME Record | docs |
custom-docs.provider.net. |
Automatic | Docs host |
Step 1: Check That the Domain Uses Namecheap DNS
Records you add in Namecheap only work if Namecheap’s nameservers answer for the domain. If it points to external nameservers (Cloudflare or a web host, for example), create the records there instead.
- Log in to Namecheap and go to your Domain List.
- Click Manage next to your domain.
- Find the Nameservers section under the Domain tab.
- Make sure the dropdown is set to Namecheap BasicDNS (PremiumDNS and FreeDNS work the same way). With Namecheap Web Hosting DNS, records are managed in cPanel instead of Advanced DNS.
- If you changed it, hit the green checkmark to save.
Switching nameservers moves every record, including email. If you are changing them now, first read how to point Namecheap DNS to your host without breaking email.
Step 2: Add an A Record for Each Server
An A record maps a subdomain to an IPv4 address. Use it for a VPS, dedicated server or cloud VM with a static public IP.
For example, if your API server’s IP is 198.51.100.42 and you want it at api.example.com:
- In Namecheap, open the Advanced DNS tab.
- Scroll to Host Records and click Add New Record.
- Choose A Record for the Type.
- In the Host field, enter only the subdomain prefix:
api(do not typeapi.example.com). - In the Value field, paste your server’s IPv4:
198.51.100.42. - Set TTL to Automatic (or 5 min if you’re testing and want changes to apply fast).
- Click the green checkmark to save.
Check the record right away by asking Namecheap’s nameserver directly from your local terminal:
dig +short api.example.com @dns1.registrar-servers.comThis skips your ISP’s cache. It should print 198.51.100.42 and nothing else. An empty result means the record is not saved yet or the Host field has a typo.
If the Subdomain Is Hosted on Hostinger
Shared and cloud hosting needs one extra step, because the server only answers for hostnames it knows about. Create the subdomain in the Subdomains section of hPanel first, then point the A record in Namecheap at the IP address shown in your hosting plan details. Once the record resolves, install the free SSL certificate for the subdomain from the SSL section of hPanel.
Step 3: Add a CNAME Record for Each Hosted Platform
A CNAME record makes a subdomain an alias of another hostname instead of an IP. Use it for SaaS platforms, documentation hosts and storage or CDN origins that manage their own changing IPs.
For example, to point docs to a provider endpoint such as custom-docs.provider.net:
- Under Host Records, click Add New Record.
- Select CNAME Record.
- In the Host field, type
docs. - In the Value field, enter your provider target:
custom-docs.provider.net. - Set TTL to Automatic and click the checkmark to save.
Most platforms also ask you to add the subdomain in their own dashboard, so they know to serve your content and issue a certificate for it. Do that as well, or the platform shows its own “not found” page.
Step 4: Configure the Web Server for the Subdomain
DNS only delivers visitors to the right IP address. The web server on that machine then reads the requested hostname (the Host header) and must send it to the right app instead of a default page.
On your API server, this Nginx server block sends api.example.com to a local backend on port 3000:
server {
listen 80;
listen [::]:80;
server_name api.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}Save it as /etc/nginx/sites-available/api.example.com. Then, over SSH on the same server, enable it, test the configuration and reload Nginx:
sudo ln -s /etc/nginx/sites-available/api.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxnginx -t should report that the syntax is ok and the test is successful. If it prints an error, fix the line it names before reloading. For a longer walkthrough of this part, see how to point a Namecheap subdomain to a separate server with Nginx.
Step 5: Issue an SSL Certificate on Each Server
Each subdomain lands on a different machine, so each machine needs a certificate it can serve. You have two realistic options:
- Independent Let’s Encrypt Certs (Recommended): Run Certbot on each server for its specific subdomain. Zero cert syncing required.
- Wildcard SSL Certificate: Generate a single
*.example.comcert via DNS-01 challenges and automate copying the keys across servers.
Separate certificates are much easier to maintain. On your API server, over SSH, run:
sudo certbot --nginx -d api.example.com --non-interactive --agree-tos -m admin@example.comCertbot proves control of the name through the A record you created (the HTTP-01 challenge on port 80), then adds the SSL settings to your Nginx config. It reports that the certificate was received and deployed. If you need the wildcard route instead, follow our guide to Let’s Encrypt wildcard SSL with Certbot DNS-01.
Step 6: Verify Every Subdomain
Run these checks from your local terminal once all records are saved. The first asks a public resolver for the API record, the second checks the docs CNAME, and the third requests the API over HTTPS:
dig +short api.example.com @8.8.8.8
dig +short docs.example.com CNAME @8.8.8.8
curl -I https://api.example.comThe first line should print your server IP, and the second your provider’s hostname with a trailing dot. curl should print response headers from your app with no certificate error. A certificate error means Step 5 did not finish on that server.
If It Still Doesn’t Work
The Full Domain Was Typed in the Host Field
Namecheap automatically appends your root domain to whatever you put in the Host field. If you type api.example.com, Namecheap creates a record for api.example.com.example.com. Always type just the prefix: api, docs, or staging.
A CNAME Conflicts with Another Record
According to IETF RFC 1912 (Section 2.4), a CNAME cannot exist alongside any other record for the same name. If an old A record for api is still there when you add a CNAME for api, lookups fail unpredictably. Delete the old record first.
The Old IP Keeps Coming Back
If the record you changed had a long TTL (like 4 hours), your computer and your ISP’s resolver keep the old IP until that time runs out. Flush your local DNS cache to test with fresh answers:
# On macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
# On Ubuntu / Debian (systemd-resolved)
sudo resolvectl flush-cachesThe Subdomain Shows the Wrong Site or a Default Page
DNS is correct but the web server does not recognise the hostname. Check that server_name matches the subdomain exactly, that the file is linked into sites-enabled, and that you reloaded Nginx. On hosted platforms, make sure the subdomain is added in the platform’s dashboard.
Certbot Fails with a Timeout or Connection Error
Let’s Encrypt could not reach the server on port 80. Confirm the A record already returns this server’s IP, and open port 80 in the server firewall and in any cloud firewall in front of it. Then run Certbot again.
Frequently Asked Questions
How many subdomains can I create in Namecheap DNS?
Far more than most projects need. Namecheap’s DNS limits page allows up to 800 records per domain, counting every record type. A separate Namecheap article gives a lower limit of 150 records for FreeDNS. Either way there is room for staging environments, APIs, microservices and static sites.
Can I route a subdomain to a specific port on my server?
No. A and CNAME records only map names to addresses; they do not carry port numbers. Point the subdomain at your server’s IP, then use a reverse proxy like Nginx or Caddy to forward traffic to :3000 or :8080, as in Step 4.
Will adding subdomain records affect my email delivery?
No. New A or CNAME records for subdomains do not change root-domain mail routing, as long as you leave your MX, SPF, DKIM and DMARC records alone. To double-check your existing email setup, see our guide on configuring SPF, DKIM, and DMARC records in Namecheap DNS.
How long does a new subdomain record take to work?
Usually a few minutes on Namecheap BasicDNS, because no resolver has an old answer cached. A resolver that looked the name up before it existed may remember the “no such record” answer for a short while. When you change an existing record, the wait depends on its previous TTL.
Next Steps
- Add the next subdomain the same way: record in Namecheap, server block or platform setting, then a certificate.
- Run the Step 6 checks for each subdomain after any change.
- Keep a short list of which subdomain lives on which server, so the next person who edits DNS knows what each record is for.

