Skip to content
MtrXTools

curl: (51) SSL: no alternative certificate subject name matches target host name

The certificate doesn't match the hostname

Seen in curl, Python (hostname doesn't match), Node.js (ERR_TLS_CERT_ALTNAME_INVALID)

The certificate the server sent does not list the name you connected to.

Common causes

  • The certificate is missing this name (www vs apex, or a subdomain).
  • The client connects by IP or an internal alias.
  • SNI not sent, so the server returns its default certificate.

How to fix it

  1. Add the name to the certificate's subject alternative names.
  2. Connect using a name on the certificate.
  3. Make sure the client sends SNI (all modern clients do).
See the names on the certificate

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

Related errors

All 34 Command line & code errors