kubens: error: no namespace exists with name "[name]"
Routes kubens unknown-namespace failures. Use when kubens reports no namespace exists with name. Not for list-permission denials or missing context.
kubens validates the name against the cluster before writing it into your context, and that namespace is not there - a typo, or it was deleted. List the real ones with kubectl get namespaces, then kubens the exact name. Note kubens may show the interactive list instead of switching when the name is a partial match.
The error
error: no namespace exists with name "abc".What to do
- List the real namespaces:
kubectl get namespacesExpected: Shows the namespaces that exist.
- Switch with the exact name:
kubens [exact-name] Expected: Prints Active namespace is "[exact-name]"..
- If the namespace should exist, check you are on the right context:
kubectx -candkubectl config current-context.
Expected: Confirms the cluster you are actually talking to.
When this applies
- the exact no namespace exists with name message
- namespace typos
- namespaces deleted out from under a saved context
When it does NOT apply
- Error from server (Forbidden) on namespaces (RBAC - different fix)
- current-context is not set
Works with
kubens (ahmetb/kubectx)
kubens shows the picker instead of switching on a direct match
Known UX quirk with certain fzf versions. Type the full exact name or pick from the list.
Why it happens
Unlike kubectl config set-context --namespace, which accepts anything, kubens checks the name against the API first so a typo does not silently point your context at a nonexistent namespace.
Edge cases
- RBAC that forbids listing namespaces produces this same message even when the namespace exists - check for a Forbidden line above it.
- A namespace stuck in Terminating still lists but can not be used; pick another.
Resolved from
gh:ahmetb/kubectx#155 - https://github.com/ahmetb/kubectx/issues/155
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.