Home › Kubernetes

Error: Kubernetes cluster unreachable — how to fix

Error: INSTALLATION FAILED: Kubernetes cluster unreachable: Get "http://localhost:8080/version": dial tcp 127.0.0.1:8080: connect: connection refused

Quick fix: First check kubectl cluster-info works in the same shell. If kubectl works but Helm doesn't, pass the config explicitly: helm install ... --kubeconfig ~/.kube/config or export KUBECONFIG=~/.kube/config. On k3s use export KUBECONFIG=/etc/rancher/k3s/k3s.yaml. With sudo, the root user has a different (empty) kubeconfig.

What it means

Helm uses the same client configuration as kubectl: the KUBECONFIG environment variable, or ~/.kube/config if that's unset, and the current context in it. Before installing or upgrading it calls the API server (/version). Kubernetes cluster unreachable means that call failed. The part after the colon tells you why:

Detail Meaning
http://localhost:8080/version ... connection refused No kubeconfig found; Helm fell back to the default address
dial tcp <ip>:6443: i/o timeout Kubeconfig found, but the API server isn't reachable (network, VPN, cluster down)
the server has asked for the client to provide credentials Reached the cluster, credentials rejected or expired
exec plugin: invalid apiVersion The kubeconfig's auth plugin command is too old

Always compare with kubectl in the same shell:

kubectl config current-context
kubectl cluster-info

Cause 1: Helm can't find the kubeconfig (localhost:8080)

The kubeconfig is somewhere other than ~/.kube/config and KUBECONFIG isn't set in this shell, script or CI job.

Fix 1

export KUBECONFIG=$HOME/.kube/config
helm list -A

or pass it per command:

helm upgrade --install my-app ./chart --kubeconfig /path/to/config --kube-context my-cluster

Cause 2: k3s / MicroK8s / kubeadm keep the config elsewhere

k3s writes its kubeconfig to /etc/rancher/k3s/k3s.yaml, and its bundled k3s kubectl reads it, so kubectl works while a separately installed Helm does not.

Fix 2

For k3s:

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

The file is readable only by root by default. Rather than running Helm as root, copy it for your user:

mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
chmod 600 ~/.kube/config

For MicroK8s: microk8s config > ~/.kube/config. After kubeadm init, copy /etc/kubernetes/admin.conf to ~/.kube/config the same way.

Cause 3: running Helm with sudo

sudo helm ... runs as root, whose home is /root, so Helm looks for /root/.kube/config and finds nothing.

Fix 3

Run Helm as your normal user, without sudo. If you must use sudo, pass the file explicitly: sudo helm ... --kubeconfig /home/me/.kube/config.

Cause 4: wrong context or unreachable API server

The current context points at a deleted cluster, a cluster behind a VPN, or a local cluster (minikube, kind, Docker Desktop) that isn't running.

Fix 4

kubectl config get-contexts
kubectl config use-context the-right-one
minikube status        # or: kind get clusters

Start the local cluster or connect the VPN, then retry.

Cause 5: expired or outdated cloud credentials

Managed clusters use short-lived tokens produced by a command in the kubeconfig (aws, gcloud, kubelogin). If that tool is logged out or too old, authentication fails.

Fix 5

Log in again and regenerate the kubeconfig entry:

aws eks update-kubeconfig --name my-cluster --region eu-west-1
gcloud container clusters get-credentials my-cluster --region europe-west1
az aks get-credentials --resource-group my-rg --name my-cluster

For exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1", update the AWS CLI and run aws eks update-kubeconfig again so the entry uses a supported API version.

Cause 6: Terraform's Helm provider

With the Terraform helm provider, this error means the provider's kubernetes block is missing or points at a cluster that doesn't exist yet during the plan. Configure the host, CA certificate and token explicitly from the cluster resource or data source, rather than relying on a local kubeconfig.

Last updated 2026-11-30.