Adding a manual DNS record every time an app spins up a new user workspace or staging branch gets tedious fast. If you’re building a multi-tenant SaaS, client portals, or ephemeral preview environments, you need any random prefix to resolve straight to your server without touching your registrar dashboard ever again.
Here is how to configure wildcard subdomain DNS records in Namecheap Advanced DNS, choose between A and CNAME routing, and confirm everything actually works from your terminal.

How Wildcard DNS Actually Operates
A wildcard DNS record acts as a catch-all query handler for names that don’t exist explicitly in your zone file. Under the rules outlined in RFC 4592, an asterisk (*) placed in the leftmost label tells nameservers to reply with that record’s target whenever a specific matching host isn’t found.
For example, if you assign an A record for *.example.com to IP address 198.51.100.25:
tenant1.example.comresolves to198.51.100.25testing-sandbox.example.comresolves to198.51.100.25alpha.beta.example.comwill not match under standard single-level resolver rules
Wildcards only kick in when no exact match exists. If you have a dedicated record for blog.example.com pointing to another box, resolvers pull that explicit record and ignore the wildcard entirely. Keeping that priority rule in mind will save you a lot of debugging time when you’re mixing custom landing pages with shared app clusters.
Step 1: Verify Your Namecheap Nameserver Mode
Before touching your records, make sure your domain is actually using Namecheap’s DNS. Namecheap disables the Advanced DNS tab entirely if your domain points to third-party nameservers like Cloudflare or DigitalOcean.
- Head into your Namecheap dashboard and click Domain List on the left.
- Click Manage next to your target domain.
- Find the Nameservers dropdown on the main tab.
- Check that it’s set to either Namecheap BasicDNS or Namecheap PremiumDNS.
If it says “Custom DNS”, anything you configure inside Namecheap’s panel will be ignored by upstream resolvers. If you recently pointed nameservers to Hostinger or another web host, check our tutorial on how to point Namecheap DNS to Hostinger without breaking email to make sure you’re editing records in the right place.
Step 2: Add a Wildcard A Record in Advanced DNS
Use a Wildcard A record if your app lives on a VPS, dedicated cloud instance, or bare-metal server with a static IPv4 address.
- Open the Advanced DNS tab inside domain management.
- Scroll down to the Host Records table. Clear out any dead test subdomains so they don’t override your wildcard.
- Click Add New Record.
- Choose A Record from the Type dropdown.
- In the Host field, enter an asterisk:
* - In the IP Address field, enter your server’s public IP (e.g.,
142.250.190.46). - Set TTL to 1 min (or Automatic). Keeping TTL short during rollout means a typo won’t ruin your afternoon.
- Click the green checkmark to save.
Here is what the finished row looks like in Namecheap:
- Type: A Record
- Host:
* - Value:
YOUR_SERVER_IP - TTL:
Automatic(or1 min)
Step 3: When to Use a Wildcard CNAME Instead
If your stack sits behind a PaaS, a managed load balancer, or an edge platform without static IPs, use a CNAME instead of an A record.
In Namecheap Advanced DNS:
- Click Add New Record.
- Select CNAME Record.
- Enter
*for the Host. - Enter your platform endpoint in the Target field (for example,
custom-ingress.herokudns.com.or an AWS ALB hostname). - Leave TTL on Automatic and save.
Remember that standard DNS specs forbid coexisting CNAMEs with other records on the exact same label. While that restriction usually bites developers on root domains, Namecheap works around it on apex zones using ALIAS records. If you need similar forwarding for your base domain, take a look at our guide on how to point an apex domain to a CNAME in Namecheap DNS with ALIAS records.
Step 4: Verify the Record with Dig and Host
Skip the browser for this step. Local DNS caches, OS mDNS daemons, and browser caching will lie to you about whether a record propagated. Query public resolvers directly from your terminal.
I usually check against Google’s resolver with dig:
dig +short test-customer-123.example.com @8.8.8.8
198.51.100.25 dig +short random-uuid-491.example.com @1.1.1.1
198.51.100.25You should see your server IP come back in the ANSWER section in under 50ms. If you prefer the cleaner output of host, run this instead:
host staging-fleet-09.example.com 8.8.8.8If you get back NXDOMAIN, double-check your Namecheap panel. The most common mistake is typing *.example.com into the Host input. Namecheap automatically appends your root domain behind the scenes, so doing that actually creates *.example.com.example.com.
Step 5: Catch-All Routing on Your Web Server
Getting the DNS query to hit your IP is only step one. Your web server (Nginx, Caddy, Apache, or a raw Node process) needs to actively accept traffic for arbitrary host headers instead of dropping unmatched requests.
Nginx Configuration
Add a wildcard pattern or capture regex to your server_name directive inside your virtual host config:
server { listen 80; listen [::]:80; server_name example.com *.example.com; root /var/www/tenants/public; index index.php index.html; location / { try_files $uri $uri/ /index.php?$query_string; }
}If your backend needs to route requests based on the subdomain slug, capture it cleanly in Nginx using a named regex group:
server { listen 80; server_name ~^(?.+).example.com$; location / { proxy_set_header X-Tenant-ID $subdomain; proxy_pass http://127.0.0.1:3000; }
}Always run sudo nginx -t before applying anything. If the test passes, reload it with sudo systemctl reload nginx.
Node.js Host Header Handling
If you’re running Express or a basic Node HTTP server behind a reverse proxy, you can pull the customer workspace straight off the request host header:
import express from 'express';
const app = express(); app.use((req, res, next) => { const host = req.headers.host || ''; const parts = host.split('.'); if (parts.length > 2) { req.subdomain = parts[0]; } else { req.subdomain = null; } next();
}); app.get('/', (req, res) => { if (!req.subdomain) { return res.send('Welcome to the main marketing site'); } res.send(`Rendering private workspace for tenant: ${req.subdomain}`);
}); app.listen(3000, () => { console.log('App listening on port 3000');
});With this in place, any new workspace provisioned in your database is live immediately. No restarts, no config changes, and no touching DNS.
The Gotcha: Wildcard Subdomains and SSL Certificates
This is where almost everyone hits a wall. You set up the wildcard, dig resolves cleanly, you open the URL in Chrome, and boom: ERR_SSL_COMMON_NAME_INVALID.
Single-domain certs won’t touch wildcard subdomains. On top of that, standard automated HTTP-01 challenges through Let’s Encrypt can’t issue wildcard certificates. As noted in the Let’s Encrypt challenge documentation, wildcard certificates (*.example.com) strictly require the DNS-01 challenge.
To request a free wildcard certificate using Certbot with manual DNS validation, run:
sudo certbot certonly --manual --preferred-challenges=dns -d example.com -d "*.example.com"Certbot will pause and hand you a verification token:
Please deploy a DNS TXT record under the name:
_acme-challenge.example.com
with the following value:
L9xKj_example_token_string_here_abc123xyzHere is what to do next:
- Head back into Namecheap Advanced DNS.
- Add a new TXT Record.
- Set the Host to
_acme-challenge. - Paste the token into the Value field and set TTL to 1 min.
- Wait about 60 seconds, verify it with
dig TXT _acme-challenge.example.com @8.8.8.8, and only hit Enter in your terminal once the TXT answer shows up.
If manual renewals every 90 days sound miserable for your setup, buy a commercial wildcard cert or switch DNS to a provider with a supported Certbot API hook. You can read our walkthrough on how to install a custom Namecheap SSL certificate on Hostinger if you prefer dealing with long-lived commercial certs.
Wildcard Subdomain Precedence and Conflicts
DNS resolution rules can surprise you once you start mixing wildcard subdomains with staging environments, preview branches, and corporate email.
1. Explicit Records Always Win
If you have a dedicated A record for app.example.com pointing to 192.0.2.1, and a wildcard *.example.com pointing to 198.51.100.25, queries for app.example.com will always go to 192.0.2.1. The wildcard only answers for hosts that don’t already exist. That makes it completely safe to add a wildcard without breaking existing services.
2. Single Label Matching Only
Standard DNS wildcards only match a single dot-separated label. A record for * matches tenant.example.com, but it won’t resolve nested names like preview.tenant.example.com. If you need multi-level wildcarding, you have to add a separate wildcard for that branch, such as *.tenant in Namecheap’s Host column.
3. MX and TXT Record Collisions
Avoid setting a wildcard MX record (Host: *) unless your mail server is deliberately built to handle inbound mail for arbitrary addresses like ops@client1.example.com. Keep your MX records tied strictly to @ and explicit subdomains so you don’t inadvertently route garbage mail to your primary server.
Frequently Asked Questions
Can I point a wildcard subdomain to an IP and an apex domain to a CNAME?
Yes. You can run a wildcard A record (Host: *) pointing to your compute server while using an ALIAS or CNAME on the apex (Host: @) to send root domain traffic to another platform.
How long does it take for a wildcard record to propagate in Namecheap?
Namecheap’s authoritative servers update within 60 to 120 seconds. However, if you or your users tested an unconfigured subdomain right before adding the record, recursive resolvers (like 8.8.8.8 or your ISP) may cache that negative NXDOMAIN response for 15 to 30 minutes.
Will a wildcard subdomain record break my existing root domain website?
No. A wildcard on * strictly matches subdomains. It will never intercept requests aimed at example.com. Your root site still relies entirely on whatever record you assigned to @.
Why does my browser display an SSL warning on my new wildcard subdomains?
A standard SSL certificate only protects example.com and www.example.com. For dynamic subdomains, you need a wildcard certificate covering *.example.com, issued via a DNS-01 verification challenge or bought through a commercial CA.
Next Steps for Your Infrastructure
Once your Namecheap records are handling traffic, make sure your proxy layer and reverse-proxy caches don’t drop the ball. If you’re routing through an external edge network, take a look at our guide on how to configure end-to-end SSL across Namecheap, StackPath, and Hostinger to prevent edge-to-origin handshake failures.

