Skip to content

The connection to the server localhost:8080 was refused

kubectl didn’t find a usable kubeconfig, so it tried its built-in default of localhost:8080, where nothing is listening.

Terminal window
echo "$KUBECONFIG"
ls -l ~/.kube/config
kubectl config current-context
Cause Fix
No ~/.kube/config for this user Copy or generate the kubeconfig (for kubeadm, from /etc/kubernetes/admin.conf; for managed clusters, the provider’s CLI)
Running as a different user, often with sudo sudo uses root’s home directory; run without it, or set KUBECONFIG
KUBECONFIG points at a missing file Fix the path
Current context points at nothing kubectl config use-context <name>
On a control plane node, right after kubeadm init Follow the printed instructions to copy admin.conf to ~/.kube/config

admin.conf grants full cluster-admin access. Don’t copy it to laptops or CI systems; use per-person credentials from your identity provider instead.