HTTP 404 Not Found: causes, how to debug it and what to return instead

Open this example in the tool

Try it in the tool

HTTP Status Codes

Every HTTP status code with its RFC, meaning and when to use it.

URL Parser

See every part of a URL, decoded, with the gotchas pointed out.

HTTP 404 Not Found means the server could not find anything to serve at the URL you asked for. It is defined in RFC 9110, section 15.5.5. The server is working, and it understood the request; the problem is the address or the missing resource. A server may also use 404 on purpose, to avoid telling you that a protected resource exists.

The usual causes

  • A typo or an old link: the URL was copied wrongly, or the page moved and nothing redirects the old address.
  • A wrong base path: the app lives under /app/ but a link or an asset points at /.
  • Case: /Docs/Intro.html and /docs/intro.html are two different files on a Linux server.
  • A trailing slash: some servers treat /guide and /guide/ as different, and a static host may only have the folder version.
  • The file was never deployed: it is ignored by git, excluded by the build, or the build output is in another folder.
  • Single-page app routing: the browser handles /settings in JavaScript, but a refresh sends that path to the server, which has no such file. The server needs a rule that returns index.html for application routes.
  • A routing rule in the framework: a route was not registered, or an if fell through to the default.

Debug a 404 in three steps

  1. Look at the exact request, not at what you meant to type. Paste the URL into the URL parser to see the path, the query and the fragment separately, and any %20 or double encoding in the path.
  2. Request it from a terminal: curl -i https://example.com/missing shows the real status, the headers and the body, without the browser’s cache. Add -L to follow redirects and see which hop ends in 404.
  3. Check the server’s log: nginx and Apache write the file path they looked for. If the path is not what you expected, the problem is in the configuration (root, alias, rewrite rules), not in the page.

What to return instead of a plain 404

Situation Use
The page never existed, or you do not know 404
The page was removed on purpose and will not come back 410 Gone
The page moved a redirect, 301 for a permanent move
The user may not see it, and you want to hide that it exists 404 instead of 403

Make your 404 page useful, and correct

Send the status 404 along with the page. A friendly page that answers 200 is a soft 404 and confuses crawlers. On the page itself, keep the site header, add a search box or links to the main sections, and say what the visitor can do next. For static hosting, name the file 404.html in the location the host expects.

Remember that API clients read the status first. A JSON API should return 404 with a JSON body such as {"error":"user_not_found"}, not an HTML page.

Search 404 and 410 together in the HTTP status codes tool to compare them side by side. Authentication problems are a different family: see 401 and 403.

Frequently asked questions

What is the difference between 404 and 410?

404 says there is nothing here now, and says nothing about later. 410 says the page existed and was removed on purpose, for good. Search engines drop a 410 URL slightly faster, so use it for content you really deleted.

What is a soft 404?

A page that shows 'not found' text but returns status 200. Search engines see a normal page and may index it. Always send the 404 status together with the not-found page; a single-page app needs the server or CDN to do that.

Do 404 errors hurt my search ranking?

A 404 for a URL that should not exist is normal and does no harm. It becomes a problem when pages that used to rank return 404 without a redirect, or when your own internal links point at missing pages.

Why does a URL work on my laptop and give 404 on the server?

Linux servers treat file names as case sensitive, and macOS and Windows usually do not, so Logo.PNG and logo.png are different files there. Another cause is a file that was not part of the deploy or a path that depends on the folder you started from.

More in this reference