Your kubectl cannot connect to the Kubernetes API server. This prevents any cluster management operations.
When kubectl cannot establish a TCP connection to your Kubernetes API server, it returns a connection refused error. This typically means the API server is not listening on the specified address, is unreachable due to network issues, or the server process has crashed. The kubeconfig file may also point to an incorrect server address or port.
Check your kubeconfig file:
kubectl config viewLook for the server: field. Typical format: https://10.0.0.1:6443 or https://kubernetes.default.svc.cluster.local
Try a direct connection:
curl -k https://YOUR_API_SERVER:6443If you get connection refused, the server is not listening.
On the control plane node:
kubectl get nodes
# Or on control plane:
sudo systemctl status kubelet
sudo systemctl status kube-apiserverIf using kubeadm, check pod status:
kubectl get pods -n kube-system | grep apiserverFor kubeadm clusters:
sudo systemctl restart kubeletFor managed services (EKS, GKE), use the cloud console to check and restart the cluster control plane.
If the address is wrong, update it:
kubectl config set-cluster kubernetes --server=https://CORRECT_IP:6443Or manually edit ~/.kube/config and change the server field.
For managed Kubernetes (EKS, GKE, AKS), connection issues often indicate control plane health. Check cloud provider dashboards. For on-premises clusters, monitor etcd and API server logs. Ensure client certificates in kubeconfig are not expired (check with openssl x509 -in cert.crt -text -noout). In load-balanced setups, verify the load balancer is routing correctly to all control plane nodes.
Failed to connect to server: connection refused (HTTP/2)
How to fix "HTTP/2 connection refused" error in Kubernetes
No subnets found for EKS cluster
How to fix "eks subnet not found" in Kubernetes
missing request for cpu in container
How to fix "missing request for cpu in container" in Kubernetes HPA
unable to compute replica count
How to fix "unable to compute replica count" in Kubernetes HPA
error: context not found
How to fix "error: context not found" in Kubernetes