Free auditStart free
GuideError · HTTP status codes

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.

4 min
read
7
sources
Oct 23, 2026
updated
Scaplet Editorial Team
author
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?
  2. Common nginx causes and fixes
  3. Find the exact reason in two minutes
  4. 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 withChatGPTClaudePerplexityGoogleAI Mode
01Explained

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 is on the 404 Not Found page.

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.

02nginx 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.

03How it works

Find the exact reason in two minutes

  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.

04Explained

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 after config changes. See 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. 01Module ngx_http_core_module - nginx documentationnginx.org · checked 2026-10-25
  2. 02Core functionality (error_log) - nginx documentationnginx.org · checked 2026-10-25
  3. 03Command-line parameters - nginx documentationnginx.org · checked 2026-10-25
  4. 04Module ngx_http_proxy_module - nginx documentationnginx.org · checked 2026-10-25
  5. 05404 Not Found - HTTP - MDN Web Docsdeveloper.mozilla.org · checked 2026-10-25
  6. 06How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-10-25
  7. 07RFC 9110: HTTP Semanticsrfc-editor.org · checked 2026-10-25
Questions

Asked a lot.

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

01Why 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.

02How 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.

03What 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.

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

End try_files with /index.html, as in the 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.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

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

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane