What the message looks like
NET::ERR_CERT_COMMON_NAME_INVALID – This server could not prove that it is www.example.com; its security certificate is from example.com.Common causes
- Certificate covers example.com only, but www.example.com is requested (or the other way round).
- nginx serves another vhost's certificate because no
server_namematches and thedefault_serveranswers. - A new subdomain was added but the certificate was not expanded.
- Access via IP address or an internal hostname.
- DNS points to a different server, e.g. an old hoster or a CDN without a matching certificate.
Check
- Show the names in the served certificate (SAN)
- Show existing Let's Encrypt certificates and their domains
certbot certificates 2>/dev/null | grep -E 'Certificate Name|Domains' - Show server_name, certificate paths and default_server
nginx -T 2>/dev/null | grep -nE '^\s*(server_name|ssl_certificate|listen .*default_server)' - Check that both names point to the same server
Fix
- Expand the certificate with the missing name:
certbot --nginx --expand -d example.com -d www.example.com. - Create a matching
server_namewith the rightssl_certificatefor every name. - Set up a separate
default_serverwith a dummy certificate andreturn 444;so wrong names never hit a customer site. - Check DNS if the certificate comes from a foreign server.
- After changes run
nginx -t && systemctl reload nginx.
Typical scenario
The website example.com has a valid Let's Encrypt certificate. After a marketing campaign someone links https://www.example.com and visitors see 'NET::ERR_CERT_COMMON_NAME_INVALID'. The certificate was issued only for the name without www. Use echo | openssl s_client -connect www.example.com:443 -servername www.example.com | openssl x509 -noout -ext subjectAltName to see which names are in the certificate. Remember that a name only counts through the SAN list.
FAQ
Is the common name (CN) in the certificate enough?
No. Modern browsers ignore the CN and only check the SAN list. Self-made certificates therefore need a subjectAltName.
Does a wildcard certificate cover the apex domain?
No. *.example.com covers www.example.com, but not example.com itself and not a.b.example.com. The apex must be listed too.
Why is the Common Name not enough?
Modern browsers evaluate only the Subject Alternative Names and ignore the Common Name. A certificate where the desired host appears only in the CN is rejected. All names, including the main name, have to be entered as SANs.
Does a wildcard certificate also cover the main domain?
No. *.example.com matches www.example.com or app.example.com, but not example.com itself and not a.b.example.com. So both names are usually entered: the wildcard and the apex name.
Why do only some visitors or devices see the error?
Without SNI, for instance when accessing by IP address or with very old clients, the server returns the default vhost's certificate, which does not match the name. A different vhost can also take over the connection if server_name is wrong.