Fix SSL Certificate Name Mismatch (ERR_CERT_COMMON_NAME_INVALID)

Why browsers and curl reject a certificate that does not match the hostname (ERR_CERT_COMMON_NAME_INVALID, no alternative certificate subject name matches), how SAN and wildcard matching work, and how to find and fix the wrong certificate.

Home › Guides › SSL certificate name mismatch

Last updated 18 November 2026

Quick answer

The server presented a certificate that doesn't list the name you connected to. Clients match the hostname against the DNS names in the certificate's Subject Alternative Name (SAN) extension, not the Common Name: RFC 9525 says the Common Name MUST NOT be used to identify a service, and the CA/Browser Forum Baseline Requirements make subjectAltName mandatory in publicly trusted server certificates (for DV, IV and OV certificates a commonName is NOT RECOMMENDED and, if present, must come from the SAN). It is almost always one of these:

  1. The name is missing from the SAN list, for example the certificate covers www.example.com but not example.com, or a new subdomain was added later. Fix: reissue the certificate with every name.
  2. The server sends the wrong certificate, usually its default one, because the site isn't configured for that name or the client didn't send SNI. Fix: configure the certificate for that name.
  3. DNS points at the wrong server (an old IP, another load balancer node, a CDN or parking page). Fix: correct DNS or the server behind it.
  4. You connected with a name the certificate was never meant for: an IP address, a short internal name, or a captive-portal Wi-Fi network intercepting the connection.

The error in different clients

ClientErrorSource
Chrome and Chromium browsersNET::ERR_CERT_COMMON_NAME_INVALID (net error -200)Chromium describes it as a certificate whose common name did not match the host name.
curl (OpenSSL builds)SSL: no alternative certificate subject name matches target hostname 'www.example.com'curl's OpenSSL backend; releases such as 7.88.1 write target host name. Exit code 60 (CURLE_PEER_FAILED_VERIFICATION).
curl, certificate with no DNS or IP SANSSL: certificate subject name '...' does not match target hostname '...'curl only falls back to the subject CN when the certificate has no DNS or IP SAN entries.
Node.jsERR_TLS_CERT_ALTNAME_INVALIDThe host name/IP of the peer did not match any of the subjectAltNames in its certificate.
OpenSSLX509_V_ERR_HOSTNAME_MISMATCH: hostname mismatchX509_STORE_CTX_get_error(3).

Chromium's source lists four possible reasons for -200: an attacker redirected traffic to their own server; the server is misconfigured and responding with the wrong certificate; you're on a wireless network that redirects to its login page; or the operating system added a DNS search suffix and the server has no certificate for the short name you typed.

How hostname matching works

Step 1: See which names the server's certificate covers

echo | openssl s_client -connect www.example.com:443 -servername www.example.com 2>/dev/null | openssl x509 -noout -subject -issuer -ext subjectAltName

-ext subjectAltName prints the SAN list (the OpenSSL x509 manual uses exactly this example). If the name you need isn't there, you have cause 1 or cause 2. To have OpenSSL do the check for you:

openssl s_client -connect www.example.com:443 -servername www.example.com -verify_hostname www.example.com -verify_return_error
openssl x509 -in cert.pem -noout -checkhost www.example.com

-verify_hostname checks the name during the handshake and -verify_return_error makes s_client stop on the failure (by default it carries on after verification errors). -checkhost tests a certificate file before you install it. For a mail server add -starttls smtp and connect to port 25.

Step 2: Rule out SNI and the default certificate

A server hosting several HTTPS sites on one IP picks the certificate from the SNI name the client sends in the handshake. The nginx documentation explains that without it the server can only offer the default server's certificate, because the TLS connection is set up before the HTTP request names the site. OpenSSL's s_client sends SNI from the -connect name when it's a DNS name, or the value of -servername. Compare:

openssl s_client -connect www.example.com:443 -servername www.example.com
openssl s_client -connect www.example.com:443 -noservername

If the second command returns a different certificate, the server has more than one and the name you need isn't mapped to the right one, or an old client isn't sending SNI. nginx notes SNI is mandatory to implement in TLS 1.3 but may not be used by some old or special clients, and only domain names can be sent in SNI, not IP addresses.

Step 3: Rule out DNS and individual servers

If some users see the error and others don't, one IP behind the name may be serving an old or default certificate. Test each address while keeping the real hostname for SNI and verification:

curl -sv --resolve www.example.com:443:203.0.113.10 https://www.example.com/ -o /dev/null
openssl s_client -connect 203.0.113.10:443 -servername www.example.com

curl's --resolve forces the address for that host and port, and --connect-to changes only where curl connects, not the name used for SNI and certificate checks. Find every A and AAAA record with the DNS Lookup and confirm a DNS change reached public resolvers with the DNS Propagation Checker.

Step 4: Fix it

Monitoring many certificates?

The Bulk SSL Certificate Expiry Monitor on Apify connects to each server and reads the certificate it is serving right now, on any port, including SMTP, IMAP and POP3 STARTTLS. It checks every IP behind a name, flags hostname mismatches, untrusted chains and weak keys, and can run on a schedule ($1 per 1,000 endpoints).

Related tools and guides

Check issued certificates, SAN names and expiry dates with the SSL Certificate Checker, find every A, AAAA and CAA record with DNS Lookup, confirm DNS changes with the DNS Propagation Checker, find dangling names with the Subdomain Takeover Checker and check mail hosts with the MX Record Lookup and MTA-STS Checker. Related guides: SSL certificate has expired, unable to get local issuer certificate, SSL wrong version number, SSL handshake failure and protocol version and MTA-STS and TLS-RPT setup.

FAQ

What does ERR_CERT_COMMON_NAME_INVALID mean?

Chrome received a certificate that does not list the hostname in the address bar. Despite the name, modern clients check the Subject Alternative Name entries, not the Common Name. Usually the name is missing from the certificate or the server sent the wrong certificate.

Why does curl say no alternative certificate subject name matches target hostname?

None of the DNS or IP entries in the certificate Subject Alternative Name match the host in your URL. Print them with openssl x509 -noout -ext subjectAltName and reissue the certificate or fix the server so it serves the right one.

Does a wildcard certificate cover the root domain?

No. A wildcard such as *.example.com matches exactly one label, so it covers www.example.com but not example.com or a.b.example.com. List both example.com and *.example.com in the SAN if you need both.

Why does the site work for some users but not others?

Often one IP address or load balancer node behind the name still serves an old or default certificate, or an old client does not send SNI. Test each IP with curl --resolve or openssl s_client -servername.

Is the Common Name still used for hostname checks?

Not by modern clients. RFC 9525 says the Common Name must not be used to identify a service, and the CA/Browser Forum requires a subjectAltName in public server certificates. curl only falls back to the CN when the certificate has no DNS or IP SAN.

Want the full kit?

Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.