404 Not Found

404
Not Found
!
?

Example HTTP Response

HTTP Response
HTTP/1.1 404 Not Found
Content-Type: application/json

{"error": "Resource not found"}
Common Causes
  • Typo in URL
  • Page was deleted
  • Link is outdated
Technical Details

What does this mean?

The internet's version of 'I looked everywhere and it's just not here!' Like searching for your keys in an empty pocket.

Technical Definition

The server cannot find the requested resource. The URL is not recognized.

RFC Says

"The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

Plain English:

Either the resource genuinely doesn't exist at this URL, or the server is pretending it doesn't exist (for security or privacy reasons).

"A 404 status code does not indicate whether this lack of representation is temporary or permanent."

Plain English:

404 doesn't tell you if the resource will exist in the future or existed in the past. If you want to explicitly say 'this was deleted permanently', use 410 (Gone) instead.

Common Misinterpretation

Some developers use 404 for authorization failures to hide the existence of resources. While the RFC allows this ('not willing to disclose'), it's usually better to use 403 (Forbidden) when a resource exists but the user lacks access, as it provides clearer feedback to legitimate users.

Code Snippets

Ready-to-use code for returning this HTTP status in your application:

Node.js
// Express.js
app.get('/example', (req, res) => {
  res.status(404).json({
    error: 'Not Found',
    message: 'Your error message here'
  });
});

// Native HTTP
const http = require('http');

http.createServer((req, res) => {
  res.writeHead(404, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    error: 'Not Found',
    message: 'Your error message here'
  }));
}).listen(3000);
When to Use This Code
  • Resource doesn't exist at this URL
  • When you don't want to reveal if a resource ever existed
  • Use 410 Gone if the resource was explicitly deleted
  • Use 403 if resource exists but user can't access it
SEO Handling

Indexing

404 pages are not indexed. Google removes previously indexed URLs that start returning 404, though this may take time.

Crawler Behavior

Crawlers reduce crawl frequency for 404 URLs over time. Persistent 404s are eventually dropped from Google's crawl queue.

Canonical URL Notes

If you've moved content, use 301 redirect instead of 404. This preserves SEO value and guides users to the new location.

Google Notes

Google distinguishes between soft 404s (page says 'not found' but returns 200) and hard 404s. Always return proper 404 status.

Commonly Confused With

404 Not Found FAQ

What causes a 404 Not Found error?

Typo in URL. Page was deleted. Link is outdated.

When should I use 404 Not Found?

Resource doesn't exist at this URL. When you don't want to reveal if a resource ever existed. Use 410 Gone if the resource was explicitly deleted. Use 403 if resource exists but user can't access it.