Skip to content
MtrXTools

Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames

The certificate doesn't cover this hostname

Seen in Node.js, npm, axios, node-fetch, Electron apps

Node.js received a valid certificate, but the hostname or IP you connected to is not in its subject alternative names.

Common causes

  • The certificate covers the apex but not www, or a different subdomain.
  • Connecting by IP address or an internal alias that is not on the certificate.
  • The server returned its default certificate because SNI or the Host was wrong, or a proxy presents its own certificate.

How to fix it

  1. Compare "Host:" and "DNS:" names in the error message; reissue the certificate with the missing name.
  2. Connect using a name the certificate covers.
  3. If you set a custom servername option or Host header, make sure it matches the certificate.
See the names on the certificate

Got a different message? Paste it into the error explainer.

Related errors

All 34 Command line & code errors