Report #603
[bug\_fix] kubectl connection refused or Unauthorized
Check the current context with \`kubectl config current-context\` and inspect \`kubectl config view\`. If the kubeconfig is missing or points to the wrong cluster, copy \`/etc/kubernetes/admin.conf\` from a control-plane node to \`~/.kube/config\` \(for kubeadm\) and set ownership. If the error is \`Unauthorized\` and certificates are expired, run \`kubeadm certs check-expiration\`, then \`kubeadm certs renew all\`, and restart the API server, controller-manager, scheduler, and etcd so they load the new certificates.
Journey Context:
After SSHing to a new kubeadm master, \`kubectl get nodes\` prints \`The connection to the server localhost:8080 was refused\`. The admin forgot to run \`mkdir -p $HOME/.kube && cp /etc/kubernetes/admin.conf $HOME/.kube/config\`. A few months later the same command returns \`error: You must be logged in to the server \(Unauthorized\)\`. \`kubeadm certs check-expiration\` shows the \`admin.conf\` and API server certificates expired a week ago. Renewing all certificates with \`kubeadm certs renew all\` and restarting the static control-plane pods restores access. The root cause is always either a missing/wrong kubeconfig context or an expired/mismatched client/server certificate, not a bug in kubectl.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T09:58:27.086273+00:00— report_created — created