HTTP 404 Not Found — Meaning, When to Use, and Examples
All 34 status codes · Search · Filter · Snippets · cURL Tester · Favorites
HTTP 404 Not Found is returned when the server cannot find the requested resource. It is the most famous HTTP status code. This guide covers when to use 404 vs 410 Gone, the security pattern of returning 404 instead of 403, and code examples for Express.js, Flask, and nginx.
Click any status code to see full details, code snippets, and usage guide
Frequently Asked Questions
What does HTTP 404 Not Found mean?
404 Not Found means the server cannot find the requested resource — the URL does not map to any existing content. It may mean the page was deleted, the URL was mistyped, the resource never existed, or the server is deliberately hiding a resource that exists (security pattern). It does not necessarily mean the URL will never work — use 410 Gone for deliberately deleted content.
What is the difference between 404 and 410?
404 Not Found is ambiguous — the resource may or may not have existed. 410 Gone explicitly states the resource previously existed and was permanently removed. For search engine optimization, 410 is a stronger signal for crawlers to deindex the URL immediately, while 404 may take longer. Use 410 for deliberately deleted blog posts, products, or API endpoints.
Should I return 404 or 403 to protect private resources?
From a security perspective, returning 404 instead of 403 for private resources is a best practice. A 403 reveals the resource exists and the user lacks permission — an attacker gains information. A 404 reveals nothing about whether the resource exists. This is called "security by obscurity" and is recommended for user profiles, private files, and admin endpoints.
How do I return 404 in Express.js?
res.status(404).json({ error: "Not Found", message: "Resource not found" }). For a global 404 handler, add after all routes: app.use((req, res) => { res.status(404).json({ error: "Route not found" }); }). In async route handlers, use: if (!user) return res.status(404).json({ message: "User not found" });
How do I fix 404 errors in an Angular SPA?
In Angular with routing, all URLs should serve index.html and let Angular router handle navigation. Configure your server: nginx: try_files $uri $uri/ /index.html; Apache: FallbackResource /index.html; Express: app.get("*", (req, res) => res.sendFile(path.join(__dirname, "dist/index.html")));. Without this, direct URL access or page refresh causes a server-level 404.
What is a custom 404 page and how do I set one up?
A custom 404 page provides a helpful message when a URL does not exist, rather than a generic browser error. In nginx: error_page 404 /404.html; and serve 404.html. In Express: app.use((req, res) => res.status(404).render("404")). In Angular: add a ** (wildcard) route pointing to a PageNotFoundComponent as the last route in your routing config.