# 404 Not Found on nginx

> Seeing 404 Not Found with nginx on the page? Check root versus alias, location matching, try_files and the error log to find why nginx cannot find the file.

Canonical: https://scaplet.com/errors/http/404/nginx

Guide Error · HTTP status codes

Seeing 404 Not Found with nginx on the page? Check root versus alias, location matching, try_files and the error log to find why nginx cannot find the file.

4 min

read

7

sources

Oct 23, 2026

updated

Scaplet Editorial Team

author

404 4xx · Client error

The short answer

A 404 Not Found from nginx means nginx matched the request to a location and could not find a file or route for that URL. The usual causes are a wrong `root` or `alias` path, a `location` block that catches the request, or a missing `try_files` fallback for single-page apps. Read the error log to see the path nginx tried.

1. [Is the 404 coming from nginx or from the app behind it?](#is-the-404-coming-from-nginx-or-from-the-app-behind-it)
2. [Common nginx causes and fixes](#common-nginx-causes-and-fixes)
3. [Find the exact reason in two minutes](#find-the-exact-reason-in-two-minutes)
4. [What it does to SEO](#what-it-does-to-seo)

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fnginx%20(%22404%20Not%20Found%20on%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fnginx%20(%22404%20Not%20Found%20on%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fnginx%20(%22404%20Not%20Found%20on%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fnginx%20(%22404%20Not%20Found%20on%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

_01_Explained

## Is the 404 coming from nginx or from the app behind it?

nginx can print its version on its own error pages, and the `server_tokens` directive controls that. If you proxy to an app server and the app returns its own 404, the page usually looks different, because nginx passes the upstream response along unless `proxy_intercept_errors` is on (it is off by default). That difference decides where to dig. The general meaning of the [status code](/glossary/http-status-codes) is on the [404 Not Found page](/errors/http/404).

Run `curl -si https://example.com/page` and compare the headers and body with the same request sent straight to the upstream. If the upstream answers 200 and nginx answers 404, the problem is in the nginx configuration. If both return 404, fix the app or its routes.

_02_nginx causes of 404

## Common nginx causes and fixes

Cause

### Wrong `root` path

What nginx does

Builds the file path by adding the request URI to the `root` value

Fix

Point `root` at the directory that holds the files, then reload

Cause

### `alias` used where `root` fits

What nginx does

Replaces the matched location with the alias path, so the URI part is dropped

Fix

Use `root` when the location matches the last part of the directory path

Cause

### No `try_files` fallback for a single-page app

What nginx does

Looks only for a file named by the URI

Fix

End `try_files` with an internal redirect to `/index.html`

Cause

### A more specific `location` catches the request

What nginx does

Chooses the longest matching prefix, then the first matching regex

Fix

Run through the location matching rules and adjust or reorder

Cause

### Location marked `internal`

What nginx does

Returns 404 to external requests

Fix

Remove `internal` or route requests through the intended redirect

Cause

### Upstream returned the 404

What nginx does

Passes the upstream response along (`proxy_intercept_errors` is off by default)

Fix

Fix the app route, or the `proxy_pass` URI

The nginx reference spells out how a path is built: with `root /data/w3;` inside `location /i/`, the request `/i/top.gif` is served from `/data/w3/i/top.gif`. With `alias /data/w3/images/;` in the same location, it is served from `/data/w3/images/top.gif`. Mix them up and nginx looks in the wrong directory.

Static site with a single-page app fallback

```
server { root /var/www/app; location / { try_files $uri $uri/ /index.html; } }
```

`try_files` checks for files in the order given and uses the first one found. If none exists, it makes an internal redirect to the last parameter. The last parameter can also be a status code such as `=404`, which sends that code on purpose.

_03_How it works

## Find the exact reason in two minutes

**Use an exact-match location to test**If you are unsure which location handles a URL, add a temporary `location = /probe { return 200 "ok"; }` and request it. The exact-match modifier ends the location search as soon as it matches, so you can confirm that nginx is routing the host and port you think it is.

1. 01

### Test and dump the config

`nginx -t` checks syntax and tries to open the files the config refers to. `nginx -T` does the same and also prints the configuration, so you see which server and location blocks nginx really loaded.
2. 02

### Read the error log

The default is `error_log logs/error.log error;`, though packages often move it. The `error` level and above are logged, which includes file-not-found problems unless `log_not_found` is off.
3. 03

### Check `log_not_found`

It defaults to on. If someone switched it off, missing files will not appear in the error log, which makes a 404 look unexplained.
4. 04

### Verify the path on disk

Join the `root` value and the request URI by hand and look for that file. Compare the filename character for character, including case.
5. 05

### Reload and retest

Run `nginx -s reload` after a change, then repeat the same `curl` request.

_04_Explained

## What it does to SEO

To Google, an nginx 404 is the same as any other 404: the URL is not indexed, and an indexed URL that starts returning it is removed. The risk is a configuration mistake that returns 404 for pages that should exist, such as a deploy that changes `root`. Watch [Search Console](/glossary/google-search-console) after config changes. See [4xx errors](/seo-issues/4xx-errors) for the audit steps.

Sources · 7

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- nginx.org
- mozilla.org
- google.com
- rfc-editor.org

1. 01 [Module ngx_http_core_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_core_module.html) nginx.org · checked 2026-10-25
2. 02 [Core functionality (error_log) - nginx documentation](https://nginx.org/en/docs/ngx_core_module.html) nginx.org · checked 2026-10-25
3. 03 [Command-line parameters - nginx documentation](https://nginx.org/en/docs/switches.html) nginx.org · checked 2026-10-25
4. 04 [Module ngx_http_proxy_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_proxy_module.html) nginx.org · checked 2026-10-25
5. 05 [404 Not Found - HTTP - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/404) developer.mozilla.org · checked 2026-10-25
6. 06 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-10-25
7. 07 [RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html) rfc-editor.org · checked 2026-10-25

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ Why am I seeing nginx on a 404 page?

The request reached an nginx server that found nothing for that URL. nginx's own error pages can include its version, which `server_tokens` controls. The page says nothing about your browser.

_02_ How do I see the nginx error logs?

The default is the `error_log` directive, `logs/error.log` at the `error` level, but many packages set a different path. Run `nginx -T` and search the output for `error_log` to find yours.

_03_ What is the difference between root and alias?

`root` appends the whole request URI to its path. `alias` replaces the matched location part with its path. Use `root` where the location matches the end of the directory path, as the nginx docs advise.

_04_ How do I stop 404s on a React or Vue app refresh?

End `try_files` with `/index.html`, as in the [snippet](/glossary/snippet) above, so nginx falls back to the app shell for routes that are not real files. The app's router then handles the path.

## Keep learning

[All errors](/errors)

[Learn 404 Not Found HTTP status codes](/errors/http/404) [Related 4xx errors Status codes and links](/seo-issues/4xx-errors) [Read next 404 Not Found on Apache HTTP status codes](/errors/http/404/apache) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 404 errors
[404 Not Found in IIS](/errors/http/404/iis) [404 Not Found in WordPress](/errors/http/404/wordpress) [404 Not Found on Apache](/errors/http/404/apache) [AWS Amplify 404 Not Found](/errors/cdn/amplify-404) [Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404)

Nearby in errors
[HTTP 405 Method Not Allowed](/errors/http/405)

More in 404 Not Found
[404 Not Found caused by .htaccess](/errors/http/404/htaccess) [404 Not Found in Django](/errors/http/404/django) [404 Not Found in Flask](/errors/http/404/flask) [404 Not Found in IIS](/errors/http/404/iis) [404 Not Found in WordPress](/errors/http/404/wordpress) [404 Not Found on Apache](/errors/http/404/apache) [404 Not Found on nginx](/errors/http/404/nginx)

Terms on this page
[HTTP status codes](/glossary/http-status-codes) [Google Search Console](/glossary/google-search-console) [Search snippet](/glossary/snippet)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
