Skip to content
Latchkey

kubectl "Error from server (NotFound)" on deploy in CI

NotFound means the API server has no object matching what you asked for. In CI this is usually a namespace that was never created, a typo in a name, or operating on a resource that was already deleted.

What this error means

A kubectl get/apply/rollout step returns "Error from server (NotFound)", naming the missing object or namespace.

kubectl
Error from server (NotFound): namespaces "staging" not found

# or:
Error from server (NotFound): deployments.apps "api" not found

Common causes

Namespace not created

The deploy targets a namespace that the pipeline never created.

Wrong resource name

A typo in the deployment/service name does not match any existing object.

Acting on an already-deleted resource

A rollout status or delete runs against something a prior step removed.

How to fix it

Create the namespace before applying

Terminal
kubectl create namespace staging --dry-run=client -o yaml | kubectl apply -f -

Verify names and existence

  1. List the resources to confirm the exact name (kubectl get deploy -n <ns>).
  2. Ensure prerequisite objects are applied before commands that reference them.
  3. Order the pipeline so creation precedes status/rollout checks.

How to prevent it

  • Create namespaces idempotently at the start of the deploy.
  • Reference resources by names that exist in the manifests applied first.
  • Use --ignore-not-found for cleanup steps that may run on absent objects.

Frequently asked questions

What causes ""Error from server (NotFound)""?
The deploy targets a namespace that the pipeline never created.
How do I fix "Error from server (NotFound)"?
Create the namespace before applying

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card