How to fix The connection to the server was refused in Kubernetes

KubernetesADVANCEDCRITICALUpdated Dec 6, 2025ยท 315 views

Your kubectl cannot connect to the Kubernetes API server. This prevents any cluster management operations.

Quick fix

Fixes The connection to the server was refused

kubectl config view
  1. Verify the API server endpoint in kubeconfig
  2. Test connectivity to the API server
  3. Check if the API server is running
  4. Restart the API server if needed
kubernetes โ€” error
kubectl config view
The connection to the server was refused

What this error means

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.

Typical symptoms

  • kubectl commands fail immediately with connection refused
  • Unable to deploy, delete, or query any resources
  • Cluster management completely unavailable
  • CI/CD pipelines fail on kubectl operations
  • Error occurs even for simple commands like kubectl version
  • No logs or partial output before disconnection

Common causes

  1. Kubernetes API server is not running or crashed
  2. Wrong API server address or port in kubeconfig
  3. Network connectivity issue between client and server
  4. API server process killed or restarted
  5. Firewall blocking port 6443 (default HTTPS port)
  6. Load balancer or ingress in front of API server is down

How to fix "The connection to the server was refused"

1Verify the API server endpoint in kubeconfig

Check your kubeconfig file:

bash
kubectl config view

Look for the server: field. Typical format: https://10.0.0.1:6443 or https://kubernetes.default.svc.cluster.local

2Test connectivity to the API server

Try a direct connection:

bash
curl -k https://YOUR_API_SERVER:6443

If you get connection refused, the server is not listening.

3Check if the API server is running

On the control plane node:

bash
kubectl get nodes
# Or on control plane:
sudo systemctl status kubelet
sudo systemctl status kube-apiserver

If using kubeadm, check pod status:

bash
kubectl get pods -n kube-system | grep apiserver
4Restart the API server if needed

For kubeadm clusters:

bash
sudo systemctl restart kubelet

For managed services (EKS, GKE), use the cloud console to check and restart the cluster control plane.

5Update kubeconfig to correct endpoint

If the address is wrong, update it:

bash
kubectl config set-cluster kubernetes --server=https://CORRECT_IP:6443

Or manually edit ~/.kube/config and change the server field.

Advanced notes

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.

Frequently asked questions

What does "The connection to the server was refused" mean?
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.
How do I fix "The connection to the server was refused"?
Your kubectl cannot connect to the Kubernetes API server. This prevents any cluster management operations.
What causes "The connection to the server was refused"?
Kubernetes API server is not running or crashed Wrong API server address or port in kubeconfig Network connectivity issue between client and server
Is the "The connection to the server was refused" error serious?
Yes. This is a critical-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading