HTTP 404 Not Found — What It Means and How to Fix It
The HTTP 404 Not Found status code indicates that the server could not find the requested resource. This means the client successfully communicated with the server, but the server was unable to locate anything matching the provided URL.
Essential Reading: Designing Data-Intensive Applications
The system design bible for software engineers. Learn to build reliable, scalable, and maintainable systems.
Common Causes
- Typo in the URL (e.g., incorrect path, filename, or domain)
- The resource has been moved or deleted from the server without a proper redirect
- Broken internal or external links pointing to a non-existent resource
- Misconfigured server routing or rewrite rules
- User attempting to access a private or non-existent page directly
Code Examples to Handle HTTP 404
curl -I https://httpbin.org/status/404
How to Fix It
- **Verify the URL:** Double-check the URL for any typos, incorrect capitalization, or missing parts. Ensure it matches the expected path to the resource.
- **Check for redirects:** If the resource was moved, ensure a proper 301 (Moved Permanently) or 302 (Found) redirect is in place from the old URL to the new one.
- **Inspect server logs:** Review server access logs for the specific request to see if the server registered the request and what path it was trying to resolve.
- **Examine server configuration:** For web servers like Apache or Nginx, check configuration files (.htaccess, virtual host configs) for incorrect rewrite rules or missing file paths.
- **Confirm resource existence:** On the server, verify that the file or resource corresponding to the URL actually exists at the specified location and has correct permissions.
Related Status Codes
Frequently Asked Questions
What causes HTTP 404?
HTTP 404 is primarily caused by the requested resource not being found on the server. This often stems from incorrect URLs (typos), resources being moved or deleted without redirects, or server-side configuration issues.
How do I fix HTTP 404?
To fix a 404, first verify the URL for accuracy. If you control the server, check if the resource exists at the specified path, inspect server logs for clues, and review server configuration for routing or rewrite rule errors. Implement 301 redirects for moved content.