kubectl Talking to the Wrong Cluster: Context Discipline

Symptom

"connection refused" to 127.0.0.1, or objects that should exist do not.

Root cause

current-context silently points at a kind/minikube/local cluster.

Fix, in order

1. Always know where you standkubectl config current-context
2. Inspect the candidateskubectl config get-contexts
3. Pin the context in scriptskubectl --context prod-us get pods

Prevent it coming back

Colorize the prompt by context; production contexts get scary colors.

Run it on clean infra

Spinning up a fresh box to reproduce or escape this error?

Managed cloud hosting

Related

Cloud & DevOps tool comparisons · Hardware build guides

NinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.

Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog