# HTTP 404 Not Found — Meaning, Causes & Fixes

> The server can't find anything at the requested URL.

404 is the web's most familiar error: there is nothing at this URL, or the server won't say there is. It isn't necessarily permanent — the resource might exist later — which is what separates it from 410 Gone.

For APIs, a 404 should mean the route or the specific record doesn't exist, not that a search came back empty.

- Class: 4xx Client Error
- Retry: No — change the request first
- Cacheable by default: yes
- Defined in: [RFC 9110 §15.5.5 — 404 Not Found](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.5)

## Example response

```http
HTTP/1.1 404 Not Found
Content-Type: application/json
Content-Length: 21

{"error":"Not Found"}
```

## Common causes

- A typo, a broken link, or a link to a page that moved without a redirect.
- Case-sensitive paths: `/About` and `/about` are different URLs on most servers.
- A single-page app served without a fallback, so deep links 404 on refresh.
- A deploy that dropped a file or route.
- An API record that was deleted or never existed.

## How to fix it

1. Redirect moved pages to their new URLs with 301.
2. For single-page apps, serve index.html for unknown routes and let the app render its own not-found view.
3. Return a real 404 status for missing pages — a 'not found' page served with 200 is a soft 404 that search engines flag.
4. Make the 404 page useful: a search box and links to popular pages.

## Send a 404 from your server

### Express

```
res.status(404).json({ error: "Not Found" });
```

### Next.js route handler

```
return Response.json({ error: "Not Found" }, { status: 404 });
```

### Flask

```
return {"error": "Not Found"}, 404
```

### Go net/http

```
http.Error(w, "Not Found", http.StatusNotFound)
```

### nginx

```
return 404;
```

## FAQ

### Do 404s hurt SEO?

Not in themselves — Google expects them for pages that don't exist. What hurts is internal links pointing at 404s, and important pages that 404 instead of redirecting.

### 404 vs 410?

404: not here, and it may or may not come back. 410: deliberately removed and not coming back. Google drops 410 URLs a little faster.

### What is a soft 404?

A page that says 'not found' but returns 200, or that redirects every missing URL to the homepage. Search Console flags these because the status contradicts the content.

## Related status codes

- [410 Gone](https://www.devkult.com/http/410.md)
- [301 Moved Permanently](https://www.devkult.com/http/301.md)
- [403 Forbidden](https://www.devkult.com/http/403.md)

Open the interactive page: https://www.devkult.com/http/404