Founding prices until 15 December: 30% off Pro, locked for life. See pricing

$ … Unable to connect to the server: x509: certificate signed by unknown authority

kubectl x509 certificate errors: unknown authority and wrong name

kubectl doesn't trust the API server's certificate, or the certificate doesn't cover the address used.

Kubernetes

What it means

kubectl checks the API server certificate against the CA in your kubeconfig. "Signed by unknown authority" means the CA doesn't match; "certificate is valid for X, not Y" means you connect by a name or IP that isn't in the certificate's SANs.

Causes and fixes

Most likely first. Run the check, and if it matches, apply the fix.

1. The kubeconfig has a different cluster's CA (copied from elsewhere, or the cluster was rebuilt)

Check:

kubectl config view --raw --minify | grep certificate-authority

Fix: Use the current admin kubeconfig from the control plane.

2. Connecting by a name or IP that's not in the API server certificate's SANs

Check:

openssl s_client -connect <host>:6443 </dev/null 2>/dev/null | openssl x509 -noout -ext subjectAltName

Fix: Use an address the certificate covers, or regenerate the certificate with the extra SAN.

Fix it yourself

A live machine in your browser with this problem already on it. The grader checks the result.

Open the lab

No account needed for your first tries.

Related errors