To set up wildcard subdomains in Namecheap DNS, add one A record (or CNAME record) with * in the Host field. Every subdomain you have not defined, such as acme.yourdomain.com, then resolves to your server. Multi-tenant apps and preview environments use this so each customer or branch gets its own subdomain without a new DNS record each time.
Quick answer: One * record in Namecheap Advanced DNS sends all undefined subdomains to your server. Your web server and certificate then have to accept them too.
- Confirm the domain uses Namecheap BasicDNS, PremiumDNS or FreeDNS.
- In Advanced DNS, add an A record with Host
*and your server’s IP. - Check a few random subdomains with
dig. - Add
*.yourdomain.comto your Nginxserver_name(or your Caddy site address). - Issue a wildcard certificate with Certbot’s DNS-01 challenge.
In this guide
- Before You Start
- How Wildcard DNS Works
- Step 1: Add the Wildcard Record in Namecheap DNS
- Step 2: Test Random Subdomains from the Command Line
- Step 3: Make the Web Server Accept Any Subdomain
- Step 4: Issue a Wildcard SSL Certificate (DNS-01 Challenge)
- Step 5: Read the Tenant in Your Application
- If It Still Doesn’t Work
- Frequently Asked Questions
- Next Steps

Before You Start
- Access: your Namecheap login and SSH access with
sudoon the server that will answer for the subdomains, with Nginx or Caddy installed. Certbot is needed for the certificate step. - Back up: take a screenshot of your Host Records. Adding a wildcard does not change existing records, but a screenshot lets you undo mistakes.
- Root domain:
*.yourdomain.comdoes not coveryourdomain.comitself. Keep or add a separate@record for the root. - Email note: a wildcard makes every name resolve, which changes how mail to made-up subdomains fails (see If It Still Doesn’t Work). Mail to your root domain is not affected.
- Time: about 10 minutes for DNS and 15 to 30 minutes for the server and certificate.
- Renewal: a certificate issued with Certbot’s
--manualmode does not renew itself. Plan to automate it (see the FAQ).
How Wildcard DNS Works
A wildcard DNS record uses an asterisk (*) as the hostname. It acts as a catch-all for any subdomain you have not defined in your zone.
DNS resolution follows RFC 1034 rules, checking for exact matches before hitting wildcards:
- If you already have an explicit record for
api.yourdomain.com, requests forapigo directly to that specific target. - If someone requests
random-tenant.yourdomain.comand no explicit record exists, the resolver falls back to the*wildcard. - A DNS wildcard is not limited to one level. A record for
*.yourdomain.commatchesapp.yourdomain.comand alsosub.app.yourdomain.com, as long as no record of any type exists atapp.yourdomain.com. It is wildcard TLS certificates that only cover a single level.
So you can keep sending specific subdomains elsewhere while the wildcard catches everything else. Our guide on how to route subdomains to different servers in Namecheap DNS covers those explicit records.
Step 1: Add the Wildcard Record in Namecheap DNS
Make sure your domain is actually using Namecheap BasicDNS, PremiumDNS, or FreeDNS (with Web Hosting DNS, records are managed in cPanel instead). If you delegated your domain to third-party nameservers like Cloudflare or AWS Route 53, you’ll need to create this wildcard on their end instead.
- Log in to your Namecheap Dashboard.
- Head to Domain List in the left sidebar and hit Manage next to your domain.
- Open the Advanced DNS tab.
- Scroll down to Host Records and click Add New Record.
Add one of these, depending on where the subdomains should go:
| Type | Host | Value (example) | TTL | Use when |
|---|---|---|---|---|
| A Record | * |
198.51.100.25 (your server’s public IPv4) |
1 min while setting up |
You run your own server with a fixed IP |
| CNAME Record | * |
ingress.example.net. (your platform’s hostname) |
1 min while setting up |
A PaaS or load balancer gives you a hostname |
For the CNAME option, do not target a name under the same domain that only resolves because of the wildcard, or the CNAME points at itself. If you also need to set up the root domain, see our breakdown on pointing the root domain in Namecheap DNS with A vs CNAME records, because the root cannot use a CNAME.
Click the green checkmark to save. Namecheap’s BasicDNS changes usually take anywhere from 2 to 15 minutes to kick in.
Step 2: Test Random Subdomains from the Command Line
Your browser and operating system cache DNS answers, so test wildcard routing by asking resolvers directly. Run these in your local terminal with a few made-up subdomain names:
# Query Google Public DNS for a random dynamic tenant
dig +short tenant-alpha.yourdomain.com @8.8.8.8
# Query Cloudflare DNS for a secondary random tenant
dig +short staging-test-99.yourdomain.com @1.1.1.1
# Check authoritative responses from Namecheap nameservers directly
dig +short random123.yourdomain.com @dns1.registrar-servers.comIf your wildcard A record points to 198.51.100.25, all three queries should return that exact IP. If you get NXDOMAIN or nothing back, double-check your Namecheap records to make sure there are no trailing spaces around the * character in the Host field. On Windows, nslookup tenant-alpha.yourdomain.com 8.8.8.8 gives the same answer.
Step 3: Make the Web Server Accept Any Subdomain
DNS now sends every subdomain to your IP. Your web server also has to accept those hostnames; otherwise it serves its default site or rejects the request.
Nginx Wildcard Server Block
On the server, open your Nginx site configuration (usually /etc/nginx/sites-available/yourdomain.conf) and add the wildcard pattern to server_name:
server {
listen 80;
listen [::]:80;
server_name yourdomain.com *.yourdomain.com;
# Optional: extract the tenant slug from the Host header
set $tenant_id "default";
if ($host ~* "^([a-z0-9-]+)\.yourdomain\.com$") {
set $tenant_id $1;
}
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
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_set_header X-Tenant-ID $tenant_id;
}
}The optional if block copies the first part of the hostname (the tenant slug) into an X-Tenant-ID header for your app. Test the syntax and reload Nginx:
sudo nginx -t && sudo systemctl reload nginxnginx -t should report that the syntax is ok and the test is successful, and only then does Nginx reload. If it prints an error instead, fix the line it names. The official Nginx server_names documentation explains how wildcard names are matched.
Caddy Wildcard Configuration
If you use Caddy instead, set up wildcard matching and the reverse proxy in your Caddyfile:
*.yourdomain.com, yourdomain.com {
tls /etc/letsencrypt/live/yourdomain.com/fullchain.pem /etc/letsencrypt/live/yourdomain.com/privkey.pem
reverse_proxy 127.0.0.1:3000 {
header_up X-Real-IP {remote_host}
}
}The tls line uses the certificate from Step 4 (Caddy’s user needs read access to the files). Without it, Caddy tries to issue the wildcard certificate itself, which requires a DNS provider module.
Step 4: Issue a Wildcard SSL Certificate (DNS-01 Challenge)
Let’s Encrypt only issues wildcard certificates through the DNS-01 challenge. The ordinary HTTP-01 challenge (a file served on port 80) does not work for wildcards. As the Let’s Encrypt Challenge Types documentation explains, you prove control by creating a _acme-challenge TXT record in your DNS zone. For a fuller walkthrough, including automated renewal, see our guide to Let’s Encrypt wildcard SSL with Certbot DNS-01 on Nginx.
On the server, run Certbot in manual mode:
sudo certbot certonly --manual --preferred-challenges=dns -d "yourdomain.com" -d "*.yourdomain.com"Certbot prints a validation string and pauses:
Please deploy a DNS TXT record under the name:
_acme-challenge.yourdomain.com
with the following value:
9kXyA6Z_EXAMPLE_TOKEN_L4m0PqRtUvWxYz12345678Now go back to Namecheap and create the validation record:
- Open your Namecheap Advanced DNS tab.
- Click Add New Record and select
TXT Record. - In Host, enter
_acme-challenge(Namecheap automatically handles the root domain part). - In Value, paste the hash string Certbot gave you.
- Set the TTL to
1 minand save.
Certbot asks for two values, one per name. After you press Enter on the first prompt it shows a second value for the same _acme-challenge name: add it as a second TXT record and keep the first.
Before the final Enter in your Certbot terminal, check from a second terminal that public resolvers can see both TXT values:
dig +short TXT _acme-challenge.yourdomain.com @8.8.8.8Once dig returns both challenge values in quotes, press Enter in Certbot. It verifies the records and saves the certificate files to /etc/letsencrypt/live/yourdomain.com/. You can delete the two TXT records afterwards.
Then update your Nginx configuration to serve HTTPS on port 443:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name yourdomain.com *.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
}
}Run sudo nginx -t && sudo systemctl reload nginx again, then open a random subdomain over https:// to confirm the certificate is accepted.
Step 5: Read the Tenant in Your Application
Once a request reaches your backend, read the incoming Host header to decide which tenant’s data or view to show.
Here is a small Express middleware example (Node.js). Save it as app.js in your project folder on the server and install Express with npm install express. It listens on port 3000, behind the Nginx configuration above:
const express = require('express');
const app = express();
const ROOT_DOMAIN = 'yourdomain.com';
app.use((req, res, next) => {
const hostname = req.hostname;
if (hostname === ROOT_DOMAIN || hostname === `www.${ROOT_DOMAIN}`) {
req.tenant = null;
return next();
}
if (hostname.endsWith(`.${ROOT_DOMAIN}`)) {
const tenantSubdomain = hostname.replace(`.${ROOT_DOMAIN}`, '');
req.tenant = tenantSubdomain.toLowerCase();
return next();
}
req.tenant = null;
next();
});
app.get('/', (req, res) => {
if (!req.tenant) {
return res.send('Welcome to the Main Marketing Site');
}
res.json({
status: 'success',
tenant: req.tenant,
message: `Displaying dashboard for workspace: ${req.tenant}`
});
});
app.listen(3000, () => {
console.log('App server listening on port 3000');
});Start it with node app.js (or your process manager), then open https://acme.yourdomain.com/. You should get a JSON response with "tenant": "acme", while the root domain shows the marketing message.
If It Still Doesn’t Work
Mail to Made-Up Subdomains Reaches Your Web Server
A wildcard A record makes every subdomain resolve, so mail to user@anything.yourdomain.com no longer bounces as “domain not found”. With no MX record at that name, sending servers fall back to the A record and try your web server instead. Your root domain’s MX records are not affected. If you want mail on a specific subdomain, give it explicit MX and SPF records, as shown in our guide to subdomain email routing with custom MX and SPF.
Multi-Level Subdomains Do Not Resolve or Get Certificate Errors
In DNS, a *.yourdomain.com record catches demo.yourdomain.com and also api.demo.yourdomain.com, unless demo.yourdomain.com has a record of its own. As soon as it does, names beneath it are no longer covered by the top-level wildcard and need their own wildcard record:
- Host:
*.demo→ matchesalpha.demo.yourdomain.com - Host:
*.staging→ matchesapp.staging.yourdomain.com
Certificates are stricter. A *.yourdomain.com certificate is valid for one level only, so api.demo.yourdomain.com needs a certificate that covers *.demo.yourdomain.com.
A Subdomain Ignores the Wildcard
That is by design: explicit records always win. If you already have a CNAME for docs.yourdomain.com pointing to an external documentation platform, Namecheap answers with that record, and the wildcard only applies when no exact match exists. Delete the explicit record if you want the wildcard to handle that name.
For how Namecheap handles wildcard and other host records, check the Namecheap host records knowledgebase article.
Certbot Says the TXT Record Is Wrong
Usually Certbot checked before both values were visible, or one value was replaced instead of added. Make sure Namecheap shows two separate _acme-challenge TXT records, wait until the Step 4 dig command prints both, and run Certbot again.
Frequently Asked Questions
Can I use a wildcard CNAME record in Namecheap?
Yes. Set the Host field to * and the Value field to your target hostname, such as a load balancer or platform app address. Add a trailing dot if your DNS provider requires fully qualified domain names. Keep the target outside the wildcard so it cannot point at itself.
Does Namecheap charge extra for wildcard DNS records?
No. Wildcard A, AAAA and CNAME records are standard DNS features with no extra charge on Namecheap BasicDNS, FreeDNS and PremiumDNS. You only pay for a wildcard SSL certificate if you buy a commercial one; Let’s Encrypt wildcards are free.
Can I automate Let’s Encrypt certificate renewals for wildcards?
Yes, and you should, because a --manual certificate does not renew by itself. Use a Certbot DNS plugin that creates and cleans up the TXT records via API. Certbot has official plugins for Cloudflare and Route 53; for Namecheap DNS there are only third-party plugins such as certbot-dns-namecheap, which need Namecheap API access (eligibility requirements and an IP allowlist apply).
How long does it take for a wildcard record to activate?
On Namecheap BasicDNS, changes typically show up across upstream resolvers in 2 to 15 minutes. Keeping your TTL at 1 minute while testing keeps cached lookups from getting in your way. Raise it to Automatic once everything works.
Next Steps
- Set up automatic certificate renewal before the manual certificate expires; our Certbot DNS-01 wildcard guide covers the options.
- Decide what your app shows for an unknown tenant slug, such as a 404 page or a sign-up prompt.
- Raise the wildcard record’s TTL from 1 minute to Automatic once testing is done.

