Portal | Level: L1: Foundations | Topics: Kubernetes Networking | Domain: Kubernetes
Runbook: Ingress Returns 404¶
Symptoms¶
- Accessing the application via ingress URL returns 404
- Service works when port-forwarded directly
- Ingress resource exists but routing fails
Fast Triage¶
# Check ingress resource
kubectl get ingress -n grokdevops
kubectl describe ingress -n grokdevops
# Check ingress controller pods
kubectl get pods -n kube-system -l app.kubernetes.io/name=traefik # k3s default
# Check service and endpoints
kubectl get svc grokdevops -n grokdevops
kubectl get endpoints grokdevops -n grokdevops
# Test service directly
kubectl port-forward svc/grokdevops -n grokdevops 8000:80
curl http://localhost:8000/health
Likely Causes (ranked)¶
- Wrong path or host in ingress spec — path doesn't match app routes
- Service name mismatch — ingress backend points to wrong service
- No endpoints — service has no ready pods (readiness probe failing)
- Ingress controller not running — traefik/nginx not deployed
- Path type wrong —
PrefixvsExactvsImplementationSpecific
Evidence Interpretation¶
What bad looks like:
$ kubectl port-forward svc/grokdevops -n grokdevops 8000:80
$ curl http://localhost:8000/health
{"status": "ok"} # works via port-forward
kubectl describe ingress — look at the Rules section for the host, path, and backend. A mismatch in any of these causes 404.
- Empty endpoints (kubectl get endpoints) means the ingress has nowhere to route traffic, which also produces 404.
Fix Steps¶
- Compare ingress path with app routes:
- Verify backend service exists and has endpoints:
- Fix ingress path if wrong:
Verification¶
curl -H "Host: <ingress-host>" http://<node-ip>/health
# or via ingress directly if DNS is configured
Cleanup¶
None needed beyond fixing the ingress resource.
Unknown Unknowns¶
[!TIP]
pathType: Exactonly matches the literal path —/withExactwill 404 on/health,/api, or any subpath. If your app has multiple routes, usepathType: Prefixor add separate Ingress rules for each path.
pathTypematters:Prefixwith/matches all subpaths,Exactwith/only matches the root — a request to/healthwould 404 withExact.- Ingress controllers may rewrite the request path before forwarding. Traefik and nginx handle path stripping differently; check annotations.
- Multiple Ingress resources with overlapping hosts/paths can conflict silently; the controller picks one and the other returns 404.
Pitfalls¶
- Not checking endpoints — if the backend service has zero endpoints (readiness probe failing), the ingress has nothing to route to. Fix readiness first.
- Testing with the wrong Host header — ingress rules are host-based;
curl http://IP/pathwithout-H "Host: ..."may hit the wrong rule or the default backend. - Forgetting the ingress class annotation — if multiple ingress controllers exist, each ingress resource must specify which controller handles it via
ingressClassNameor annotation.
See Also¶
training/interactive/exercises/levels/level-24/k8s-ingress/training/interview-scenarios/10-ingress-404.mdtraining/interactive/incidents/scenarios/service-selector-mismatch.shtraining/library/runbooks/kubernetes/readiness_probe_failed.md(if 404 is caused by empty endpoints)
Wiki Navigation¶
Related Content¶
- API Gateways & Ingress (Topic Pack, L2) — Kubernetes Networking
- Case Study: CNI Broken After Restart (Case Study, L2) — Kubernetes Networking
- Case Study: Canary Deploy Routing to Wrong Backend — Ingress Misconfigured (Case Study, L2) — Kubernetes Networking
- Case Study: CoreDNS Timeout Pod DNS (Case Study, L2) — Kubernetes Networking
- Case Study: Grafana Dashboard Empty — Prometheus Blocked by NetworkPolicy (Case Study, L2) — Kubernetes Networking
- Case Study: Service Mesh 503s — Envoy Misconfigured, RBAC Policy (Case Study, L2) — Kubernetes Networking
- Case Study: Service No Endpoints (Case Study, L1) — Kubernetes Networking
- Cilium & eBPF Networking (Topic Pack, L2) — Kubernetes Networking
- Deep Dive: Kubernetes Networking (deep_dive, L2) — Kubernetes Networking
- Docker Networking Flashcards (CLI) (flashcard_deck, L1) — Kubernetes Networking