SSL_ERROR_BAD_CERT_DOMAIN: How to Fix It Fast

Last tested: November 10, 2026 · By Alex

SSL_ERROR_BAD_CERT_DOMAIN is the error code Firefox shows when a website sends a certificate that is not issued for the hostname in the address bar. The certificate itself can be genuine, trusted and in date. It simply names a different site, so Firefox refuses to treat the connection as secure.

You normally see it on a full-page warning titled Warning: Potential Security Risk Ahead. The code only appears after you click Advanced. This guide is written for that Firefox screen: how to read what Firefox tells you, how to tell a local problem from a server problem, and how to fix the certificate or server so the names match. If you came here from Chrome or Edge, the same mismatch is called NET::ERR_CERT_COMMON_NAME_INVALID, and that guide walks through the Chrome side in depth.

Quick Fix

If you are visiting the site:

  • Click Advanced and read the line that starts with “The certificate is only valid for”. It tells you which name the server actually covers.
  • Check the address for typos, an extra www, or a staging or internal name you opened from an old bookmark.
  • Try the other form of the address (with or without www) and a Private Window.
  • If only your computer fails, turn off VPN, proxy and antivirus HTTPS scanning, then retest.

If you own the site:

  • Run openssl s_client with -servername and -verify_hostname for the exact failing name (commands below).
  • Reissue the certificate so it lists every hostname people open, including www and subdomains.
  • Make sure the right virtual host, CDN record and IP address (including IPv6) answer for that hostname.
  • Fix redirects that send visitors to a name the certificate does not cover.

What SSL_ERROR_BAD_CERT_DOMAIN Means in Firefox

How Firefox matches the hostname to the certificate SAN list; a mismatch ends in SSL_ERROR_BAD_CERT_DOMAIN
Firefox shows this error when the certificate’s names do not include the host you opened.

During the TLS handshake the server sends its certificate. Firefox takes the hostname you typed, for example www.example.com, and looks for it in the certificate’s Subject Alternative Name (SAN) list. Modern browsers, Firefox included, rely on the SAN entries and do not fall back to the old Common Name field, so a certificate with the right Common Name but no matching SAN entry still fails.

The matching rules are strict:

  • Exact names must match character for character. example.com does not cover www.example.com, and the reverse is also true.
  • Wildcards cover exactly one label. *.example.com matches shop.example.com, but not example.com and not dev.shop.example.com.
  • IP addresses only match if the certificate lists that IP as an IP address entry. Opening https://203.0.113.10 on a server whose certificate names a domain always fails.
  • Internationalised domains are compared in their punycode form (xn--...), so the certificate must contain that encoded name.

If none of the SAN entries match, Firefox stops with SSL_ERROR_BAD_CERT_DOMAIN. This is different from a broken chain or an expired certificate, which Firefox reports with other codes.

Firefox vs Chrome: Same Problem, Different Names

Where you see itHostname mismatch is reported as
Firefox (desktop and Android)SSL_ERROR_BAD_CERT_DOMAIN on “Warning: Potential Security Risk Ahead”
Chrome, Edge, Brave, OperaNET::ERR_CERT_COMMON_NAME_INVALID on “Your connection is not private”
Safari“This Connection Is Not Private” with a certificate name warning
curlSSL: no alternative certificate subject name matches target host name
openssl s_client with -verify_hostnameVerify return code: 62 (hostname mismatch)

Because Firefox uses its own certificate code base and its own settings for DNS, proxies and certificate exceptions, it can disagree with Chrome on the same computer. That makes the “works in Chrome, fails in Firefox” case worth checking separately, which this guide does below. For the general browser warning that both share, see Your Connection Is Not Private.

Other Firefox Certificate Codes You Might Confuse It With

Read the Firefox Error Details First

Firefox details: the certificate is only valid for example.com, with the error code SSL_ERROR_BAD_CERT_DOMAIN
Firefox certificate details that confirm SSL_ERROR_BAD_CERT_DOMAIN.

Firefox gives you more information on its error page than most people use. Before changing anything, collect it:

  1. On the warning page, click Advanced. Firefox writes something like “Firefox does not trust this site because it uses a certificate that is not valid for www.example.com.” and often adds “The certificate is only valid for example.com” or a list of names.
  2. Click the Error code: SSL_ERROR_BAD_CERT_DOMAIN link. Firefox expands technical details: the URL, whether HSTS applies, and the certificate chain in PEM form. The Copy text to clipboard button is handy when you need to send this to a host or administrator.
  3. Click View Certificate. Firefox opens its certificate viewer (an about:certificate page). Check Subject Alt Names for the DNS names, Issuer Name for who issued it, and Validity for the dates.

How to read the result:

  • The SAN list has example.com but not www.example.com: a coverage problem on the certificate.
  • The SAN list belongs to a completely different site or to the hosting company’s server name: the wrong virtual host or the wrong server is answering.
  • The issuer is your antivirus, VPN, school or company firewall: something on your network is intercepting HTTPS.
  • There is no “Accept the Risk and Continue” button: the site uses HSTS, which forbids exceptions. See HSTS Error for why Firefox removes the button.

Fixing SSL_ERROR_BAD_CERT_DOMAIN as a Visitor

1. Check the Exact Address

Look at the address bar, not the link you clicked. Old bookmarks often point to staging., old. or dev. names, a typo such as wwww, or a raw IP address. Type the main domain by hand and see whether the warning disappears.

2. Try a Private Window and Troubleshoot Mode

A Private Window (Ctrl+Shift+P or Cmd+Shift+P) ignores your cached site data and most extensions. If the site loads there, clear cookies and site data for that domain. If you suspect an add-on, open Help → Troubleshoot Mode, which starts Firefox with extensions disabled.

3. Compare Firefox DNS With Your System DNS

Firefox can use its own encrypted DNS (Settings → Privacy & Security → DNS over HTTPS). If it is on, Firefox may resolve the name differently from Chrome or your operating system. This matters for split-horizon setups: an internal hostname resolved by a public DNS provider can lead you to a different server with a different certificate. Switch DNS over HTTPS to Off or Default Protection for a test, restart Firefox and retry. If the error goes away, the problem is which server the name resolves to, not the certificate on the right server.

4. Check Firefox Proxy Settings and Security Software

Firefox has its own proxy settings under Settings → General → Network Settings. Set them to No proxy or Use system proxy settings for a test. Then pause the VPN and any antivirus feature called HTTPS scanning, web shield or encrypted connection scanning. If the issuer in the certificate viewer was a security product, this step usually solves it.

5. Remove an Old Certificate Exception

If you once clicked “Accept the Risk and Continue”, Firefox stored a server exception. After the site changes, that stale exception can confuse testing. Open Settings → Privacy & Security → Certificates → View Certificates → Servers, select the entry for the site and click Delete, then reload.

6. Try Another Network or Device

Load the same address on mobile data or another device. If it fails everywhere, only the site owner can fix it. If it fails only on your network, the router, captive portal or company proxy is the likely cause.

Should You Click Accept the Risk and Continue?

Only for a device you manage yourself, such as a router or NAS panel opened by IP address, and only when you know why the name does not match. Do not enter passwords or payment details on a public website showing this warning. The mismatch means Firefox cannot confirm you are talking to the real server.

Fixing SSL_ERROR_BAD_CERT_DOMAIN on Your Server

openssl s_client with verify_hostname returns code 62 hostname mismatch, and the SAN list is missing www.example.com
Use OpenSSL to inspect the certificate or handshake behind SSL_ERROR_BAD_CERT_DOMAIN.

Step 1: See Which Certificate the Hostname Really Gets

Test the exact name that fails, with SNI, and let OpenSSL check the hostname for you:

# Replace www.example.com with the failing hostname
openssl s_client -connect www.example.com:443 -servername www.example.com \
  -verify_hostname www.example.com </dev/null 2>/dev/null | grep "Verify return code"

# Show who the certificate is for
openssl s_client -connect www.example.com:443 -servername www.example.com </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -issuer -ext subjectAltName

Verify return code: 62 (hostname mismatch) confirms the problem from outside the browser. A 0 (ok) result while Firefox still complains points back to the visitor checks above (DNS over HTTPS, proxy, interception).

curl gives the same answer in one line: curl -sv https://www.example.com/ -o /dev/null fails with “no alternative certificate subject name matches target host name” when the name is missing.

Step 2: Add Every Hostname to the Certificate

List the names people actually use: the bare domain, www, and any subdomains such as shop, mail or cdn. Then make sure the certificate includes all of them. With Certbot:

# See which names your current certificates cover
sudo certbot certificates

# Reissue with every hostname (Nginx plugin; use --apache for Apache)
sudo certbot --nginx -d example.com -d www.example.com -d shop.example.com

# Or add a name to an existing certificate
sudo certbot certonly --expand -d example.com -d www.example.com

On cPanel, check that the subdomain or www record exists and points to the account, then run AutoSSL again from SSL/TLS Status. On Hostinger hPanel, reinstall the free SSL for the domain after adding the subdomain. Remember that a wildcard only covers one level, so dev.shop.example.com needs its own name or its own wildcard *.shop.example.com.

Step 3: Make Sure the Right Virtual Host Answers

On a server with several sites, a hostname that is not listed in any HTTPS server block falls through to the default site, and Firefox receives that site’s certificate. Check which block owns the name:

# Nginx: show server names and certificates
sudo nginx -T 2>/dev/null | grep -E "server_name|listen .*443|ssl_certificate "

# Apache: list virtual hosts on port 443
sudo apachectl -S

Add the missing name to server_name (Nginx) or ServerAlias (Apache) in the HTTPS block that has the right certificate:

server {
    listen 443 ssl;
    server_name example.com www.example.com;
    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}
<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>

Test and reload with sudo nginx -t && sudo systemctl reload nginx or sudo apachectl configtest && sudo systemctl reload apache2.

Step 4: Check A and AAAA Records Point to the Same Server

A classic cause after a migration: the A record was updated to the new host, but an old AAAA (IPv6) record still points to the previous server. Visitors on IPv6, and Firefox when it prefers IPv6, reach the old machine and get its certificate, which may name a different domain. Compare both:

dig +short A www.example.com
dig +short AAAA www.example.com

# Test the certificate on each address separately
curl -4 -sv https://www.example.com/ -o /dev/null 2>&1 | grep -i "subject\|subjectAltName\|no alternative"
curl -6 -sv https://www.example.com/ -o /dev/null 2>&1 | grep -i "subject\|subjectAltName\|no alternative"

Delete or correct the stale record. If DNS was changed recently, also read Website Not Working After DNS Change, because some visitors will keep the old address until caches expire.

Step 5: Check Cloudflare or CDN Coverage

If the site is behind Cloudflare, a record set to DNS only (grey cloud) sends Firefox straight to your origin, which may carry a certificate for a different name or a Cloudflare Origin CA certificate. Switch the record to Proxied, or install a public certificate for that name on the origin. Universal SSL covers the apex and one level of subdomains, so a name like dev.www.example.com needs Advanced Certificate Manager, Total TLS or its own origin certificate. The Cloudflare-side checks are covered in detail in the ERR_CERT_COMMON_NAME_INVALID guide.

Step 6: Fix Redirects That Land on an Uncovered Name

Sometimes the first hostname is fine and a redirect sends Firefox to one that is not. Follow the chain:

curl -sIL http://example.com | grep -iE "^(HTTP|location)"

# WordPress: check the stored site addresses
wp option get home
wp option get siteurl

Make every Location header end on a covered hostname. Correct rules in .htaccess, Nginx return 301 lines and CDN redirect rules, and update the WordPress Address and Site Address under Settings → General. If the redirects start looping after an HTTPS change, see Too Many Redirects After SSL.

Step 7: Retest in Firefox Without Cached Results

Firefox can reuse an existing connection for a short time. After fixing the server, close all tabs for the site, open a Private Window and load the exact hostname again. Then run an external check such as SSL Labs so you know the internet sees the new certificate, not only your own computer.

Why It Works in Chrome but Not in Firefox

Because both browsers apply the same hostname rules, a real certificate mismatch fails in both. When only Firefox fails, look at what Firefox does differently on that machine:

Firefox-only causeHow to check
DNS over HTTPS resolves the name to another serverTurn DNS over HTTPS off and retry
Firefox proxy setting differs from the systemNetwork Settings → No proxy
Stale server exception from an earlier visitView Certificates → Servers → Delete
Different IP family (IPv6 vs IPv4) reachedCompare curl -4 and curl -6
Enterprise policy or security software for Firefox onlyCheck about:policies and the certificate issuer

If the reverse happens and only Chrome complains, use the Chrome checklist in Why a Website Is Not Loading in One Browser Only.

Prevention Tips

  • Keep a written list of every hostname that serves HTTPS and check it whenever you renew or replace a certificate.
  • Issue certificates for both example.com and www.example.com even if one only redirects; the redirect itself happens over HTTPS.
  • Remove A and AAAA records for old servers during migrations instead of leaving them in place.
  • Give every site its own HTTPS server block and set a deliberate default site that does not expose another customer’s certificate.
  • Run openssl s_client -verify_hostname for each name in a monitoring script after renewals.
  • Avoid putting internal or staging hostnames in redirects, canonical tags or WordPress settings.

When to Contact Support

Contact your hosting provider if the certificate on the server names their own hostname, AutoSSL refuses to include a subdomain, or you cannot edit the web server configuration. Contact your CDN provider if the edge certificate does not cover the hostname even though the record is proxied. If the issuer is a company firewall or school network, the network administrator has to fix it. In each case, send the hostname, the time of the test and the text copied from the Firefox technical details.

Frequently Asked Questions

What does SSL_ERROR_BAD_CERT_DOMAIN mean in Firefox?

Firefox received a certificate that does not list the hostname you opened. The certificate can be valid and trusted, but it was issued for a different name, so Firefox blocks the connection.

Is SSL_ERROR_BAD_CERT_DOMAIN the same as ERR_CERT_COMMON_NAME_INVALID?

Yes, they describe the same hostname mismatch. Firefox reports it as SSL_ERROR_BAD_CERT_DOMAIN and Chrome, Edge and other Chromium browsers report it as NET::ERR_CERT_COMMON_NAME_INVALID.

How do I see which names the certificate covers in Firefox?

Click Advanced on the warning page, then View Certificate. The Subject Alt Names section lists every DNS name the certificate is valid for. Firefox also often states the valid name directly under Advanced.

Why does the error appear on www but not on the bare domain?

The certificate covers only one form of the name. Reissue it with both example.com and www.example.com, and make sure both names point to the server that holds that certificate.

Why does the site work in Chrome but not in Firefox?

Firefox can use its own DNS over HTTPS, its own proxy settings and its own stored certificate exceptions. Any of these can send Firefox to a different server or keep an outdated result. Turn them off one by one and retest.

Is it safe to accept the risk and continue?

Only on a device you control, such as a router opened by IP address. On a public website the mismatch means Firefox cannot confirm the server, so do not log in or pay there.

Final Summary

SSL_ERROR_BAD_CERT_DOMAIN is Firefox telling you the certificate names a different host. Read the Advanced details and the certificate viewer first, rule out Firefox-specific DNS, proxy and exception settings, then fix the server side: add every hostname to the certificate, make the right virtual host and IP addresses answer, keep CDN records proxied and send redirects only to covered names.

Related SSL Errors

Leave a Comment