DevOpsil
KubernetesHigh

Fix: Kubernetes Ingress Returns 404 for All Paths

All requests to the ingress return 404 Not Found

!Symptoms

  • All requests to the ingress return 404 Not Found
  • Ingress resource exists and has correct rules
  • Backend services are running and healthy
  • Direct service access via port-forward works fine

?Root Causes

  • Ingress controller not installed or not running
  • Ingress class annotation doesn't match the installed controller
  • Backend service port doesn't match the ingress rule's service port
  • Path type mismatch — using Exact when Prefix is needed
  • IngressClass resource missing or not set as default

#Diagnosis Steps

  1. 1Verify ingress controller is running: `kubectl get pods -n ingress-nginx`
  2. 2Check ingress class: `kubectl get ingressclass` and compare with ingress annotation
  3. 3Run `kubectl describe ingress <name>` — check rules and backend status
  4. 4Test the service directly: `kubectl port-forward svc/<name> 8080:<port>`
  5. 5Check ingress controller logs: `kubectl logs -n ingress-nginx <controller-pod>`

>Fix

  1. 1Install an ingress controller: `helm install ingress-nginx ingress-nginx/ingress-nginx`
  2. 2Set the correct ingressClassName in the ingress spec
  3. 3Fix service port to match: compare `spec.rules[].http.paths[].backend.service.port`
  4. 4Change pathType from Exact to Prefix if path matching is too strict
  5. 5Create a default IngressClass: `ingressclass.kubernetes.io/is-default-class: true`

*Prevention

  • Include ingress controller in cluster bootstrapping
  • Validate ingress resources in CI with kubeval or kube-linter
  • Use consistent ingressClassName across all ingress resources
  • Add smoke tests that verify ingress routing after deployment
  • Monitor ingress controller error rates in your observability stack

Related Error Messages

default backend - 404no upstream hostservice has no endpointsconnection refused