no context exists with the name ☸️ Kubernetes

error: no context exists with the name: "x"

kubectl was told to use a context that isn’t in the loaded kubeconfig file(s).

Seen on: Kubernetes

Meaning

Contexts live in ~/.kube/config or the files listed in KUBECONFIG. Cloud CLIs generate long names (arn:aws:eks:…, gke_project_zone_cluster), so a short name fails, as does a missing KUBECONFIG in CI.

Common causes

  • Typo or short name instead of the generated context name
  • KUBECONFIG points at another file
  • Kubeconfig never generated on this machine/CI runner

⚡ Quick fix

  1. List contexts: kubectl config get-contexts
  2. Generate one with the cloud CLI
  3. Rename: kubectl config rename-context <long> prod

Detailed fix by platform

Kubernetes

  1. bash
    kubectl config get-contexts
    kubectl config rename-context arn:aws:eks:eu-west-1:123456789012:cluster/prod prod
    kubectl config use-context prod

How to diagnose

  1. Files — echo $KUBECONFIG
  2. Names — get-contexts output

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.