keepcalculator

06 Numbers and Powers

Fix Wildcard Subdomain Not Accessible

Card No. 06·39586 · Updated · Standard formula, shown below

This guide walks you through diagnosing and fixing a wildcard subdomain that returns an error or fails to load. You’ll check DNS, web server configuration, and SSL settings, then test each fix until the subdomain responds correctly.

What You’ll Need

  • Access to your DNS provider’s control panel (where your domain’s A/AAAA records are managed)
  • Access to your web server configuration (Apache, Nginx, or control panel like cPanel)
  • If using HTTPS, ability to generate or modify SSL certificates (e.g., via Let’s Encrypt)
  • Command-line access to your server (SSH) for testing and editing configs

Step-by-Step

  1. Confirm the wildcard DNS record exists. Log into your DNS provider and check for an A record with host * pointing to your server’s IP (or AAAA for IPv6). If missing, add it. For example, * 300 IN A 192.0.2.1. Note: some providers require a specific format like *.example.com.
  2. Verify DNS propagation. From your local machine, run dig sub.example.com (replace sub with any subdomain) or use an online DNS checker. If the result shows your IP, the record is active. If not, wait up to 48 hours or check the TTL.
  3. Test with a direct IP request. On your server, run curl -H "Host: sub.example.com" http://localhost (or your server’s IP). If this returns your site, the web server is configured. If not, proceed to the next step.
  4. Configure the web server to catch wildcard subdomains. For Apache, add a ServerAlias *.example.com in the VirtualHost. For Nginx, add server_name *.example.com; in the server block. If using a control panel, enable the wildcard option in the domain settings.
  5. Reload the web server. After changes, run sudo systemctl reload apache2 (or nginx) to apply without restarting.
  6. Check SSL certificate coverage. If you use HTTPS, the certificate must cover the wildcard. Generate a certificate with *.example.com (and example.com) using Certbot or your provider. Ensure the certificate is installed and the web server is using it.
  7. Test again. Run curl https://sub.example.com from your local machine. If it loads, you’re done. If not, check the error message.

Common Mistakes

  • Forgetting to add the wildcard record at the DNS level—only adding it in the web server config.
  • Using an SSL certificate that doesn’t include the wildcard domain, causing a security warning.
  • Typo in the wildcard: using * as a subdomain (e.g., *.example.com vs * in some panels).
  • Not reloading the web server after config changes.
  • Conflicting VirtualHost or server blocks that override the wildcard for specific subdomains.

Tips

  • Set a low TTL (e.g., 300 seconds) on the wildcard record while testing, then increase it later.
  • Use a subdomain like test123.example.com to avoid conflicts with existing subdomains.
  • If using a CDN, ensure the wildcard record points to the CDN’s IP, not your origin server.
  • Document your wildcard setup so future changes don’t break it.

Troubleshooting

If the subdomain still doesn’t work after following the steps:

  • Check the exact error. A 404 Not Found means the web server is receiving the request but no matching server block—verify the wildcard in the config. A 502 Bad Gateway suggests a backend issue, not DNS.
  • Test DNS from a different network. Use a mobile hotspot or online tool to rule out local DNS caching.
  • Look at server logs. Check /var/log/nginx/error.log or /var/log/apache2/error.log for clues.
  • Verify the wildcard record is not overridden. Some DNS providers allow specific records to take precedence—ensure no conflicting A record for the subdomain you’re testing.
  • If using a reverse proxy, confirm that the proxy passes the Host header correctly.

Frequently Asked Questions

Why does my wildcard subdomain work on some networks but not others?

DNS propagation is not instant. Some ISPs cache records longer than others. Wait up to 48 hours, or use a public DNS like Google (8.8.8.8) to test.

Can I use a wildcard for HTTPS?

Yes, but you need a wildcard SSL certificate that covers *.example.com. Let’s Encrypt offers these via DNS-01 challenge.

Will a wildcard subdomain affect my existing subdomains?

No, if you have specific records for subdomains like mail.example.com, they take precedence over the wildcard. The wildcard only catches subdomains without an explicit record.

How do I test a wildcard subdomain without waiting for DNS?

Edit your local hosts file to point the subdomain to your server IP, then access it in a browser. This bypasses DNS entirely.

My wildcard works for HTTP but not HTTPS—what’s wrong?

Most likely the SSL certificate doesn’t include the wildcard. Reissue the certificate with *.example.com and restart the web server.

Can I set up a wildcard subdomain to point to a different port?

DNS doesn’t support ports. You’d need to configure the web server to proxy requests to different ports based on the subdomain, or use a reverse proxy.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →