Kubernetesexit code > 0

The connection to the server localhost:8080 was refused

$The connection to the server localhost:8080 was refused - did you specify the right host or port?

Analysis

Kubectl is trying to connect to a local cluster (default behavior) but cannot find one, usually because the kubeconfig file is missing or not loaded.

Common Triggers

  • Missing ~/.kube/config.
  • KUBECONFIG environment variable not set.
  • Cluster is down.

Debug Checks

  • $Check config: ls ~/.kube/config.
  • $Check env: echo $KUBECONFIG.

Resolution

1
Copy the kubeconfig from your cluster provider.
2
Set export KUBECONFIG=/path/to/config.