Skip to content
MtrXTools

certificate verify failed: Hostname mismatch, certificate is not valid for

The certificate doesn't cover this hostname

Seen in Python ssl, requests, urllib3, httpx, aiohttp

Python received a certificate that does not list the hostname or IP address it connected to.

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 the name is not configured on it, or a proxy presents its own.

How to fix it

  1. Compare the name in the error with the names on the certificate and reissue it with the missing name.
  2. Connect using a hostname the certificate covers.
  3. Check every server or load balancer behind the name serves the right certificate.
See the names on the certificate

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

Related errors

All 32 Languages & runtimes errors