DB / HTTP/Web Servers / 404
WARNING

HTTP/Web Servers Not Found

The HTTP 404 status code indicates that the server cannot find the requested resource. This is a client-side error where the URI is not recognized or the resource is no longer available at that location.

Common Causes

  • Broken or mistyped URL link on a webpage or in an API call.
  • Misconfigured web server routing or rewrite rules (e.g., in Nginx, Apache).
  • A missing file or directory after a deployment or file system change.
  • Incorrect ingress or service configuration in Kubernetes.
  • The resource was moved or deleted without a proper redirect.

How to Fix

1 Verify the Requested URL

First, double-check the URL for typos in the browser, API client, or application code. Ensure the path and query parameters are correct.

BASH
$ # Use curl to test the endpoint and see the full response curl -v https://your-domain.com/path/to/resource

2 Check Web Server Configuration

Inspect your web server (e.g., Nginx, Apache) configuration files. Ensure the `location` or `Directory` blocks are correctly pointing to the right file system path for the requested URI.

BASH
$ # Example: Check Nginx configuration syntax and test sudo nginx -t sudo systemctl reload nginx

3 Verify Deployment & File Existence

On the server, confirm that the static file or application build output exists at the expected location. This is a common issue after deployments.

BASH
$ # SSH into your server and check if the file exists ls -la /var/www/your-app/path/to/resource.html

4 Debug Kubernetes Ingress/Routing

If using Kubernetes, check your Ingress, Service, and Deployment resources. Ensure the service name and port in the Ingress match your application service.

BASH
$ # Check your ingress configuration and associated endpoints kubectl describe ingress your-ingress-name kubectl get endpoints

5 Implement Custom Error Pages or Redirects

Configure your web server or application to serve a user-friendly 404 error page or set up 301/302 redirects for old URLs to new locations.

BASH
$ # Nginx example for a custom 404 page error_page 404 /custom_404.html; location = /custom_404.html { root /usr/share/nginx/html; internal; }