AI websites

Step-by-step tutorial

Why Your AI Website Shows 404 When You Refresh a Page

A page works from your menu but returns 404 on refresh? Compare the exact request, identify your routing setup, and verify the right fix.

Product links on this page are ordinary official links. No affiliate commission is currently attached. Read our disclosure.

Quick answer

When a page works through your website’s menu but fails on refresh, check how that exact address is served on a fresh visit. Your browser may switch views without requesting a new page, while your host does not know how to serve the same address directly.

That is a clue, not a diagnosis. First distinguish a missing server response from an app displaying its own “not found” message. Then choose the repair for your site’s actual routing setup.

You need the working homepage, one failing subpage address, and access to the original project or someone who manages it. This guide covers public pages, not login or payment flows. If the homepage also fails, start with our general deployment 404 guide.

Step 1: Compare three ways to open the same page

Choose one page, such as /about, and record what happens:

Test What to record
Open the homepage, then click About Final address and visible heading
Refresh that page Whether the address changes and what appears
Paste the exact address into a new private window Whether the intended content loads directly

Keep the hostname, path and capitalization the same. Do not compare a working preview address with a different production address. A private window helps test a fresh visit; it does not prove that every cache has been bypassed.

What to check: “Click works, refresh fails, direct visit fails” gives you a specific problem to reproduce. If all three work now, do not add a routing rule just because an earlier visit failed.

Step 2: Find which request actually returns 404

In desktop Chrome, open developer tools, select Network, and reload the failing page. Select the Doc filter, then the request for that page. Read its address and status in Headers. Chrome’s Network panel guide explains how to inspect requests.

Separate these cases:

  • The page document returns 404: investigate how the host serves that path.
  • The document returns 200 but the app says “not found”: the browser received a document, but the app may not recognize the route. A server fallback alone is not enough.
  • The document returns 200 but a script, image or stylesheet returns 404: investigate that resource, not the page route. Our missing images and styles guide covers those visual assets.

Save the exact failing address, status and visible result. Do not share cookies, authorization headers or private account data when asking for help.

Step 3: Match the fix to the way your site works

A route is the address a site uses for a page or view. The important question is who handles it: generated files, browser code, or server code.

A single-page app handles navigation in the browser

A single-page application, or SPA, can load one HTML document and use JavaScript to change the visible content and address. MDN describes this pattern in its History API guide.

Clicking About inside that running app may work without a new document request. Refreshing asks the host for /about directly. If the host looks only for a file that does not exist, it can return 404 before the app loads.

For a confirmed SPA, check the host’s documented fallback or rewrite behavior: serving the app’s entry document while preserving the requested address. Sending every visitor to the homepage with a redirect is not the same repair.

Cloudflare Pages example: its serving documentation says that, without a top-level 404.html, Pages applies its default SPA behavior to paths that do not match static assets. Check the deployed output and existing rules first. Do not delete a deliberate error page from an ordinary static site simply to activate that behavior. Routes handled by server functions need their own review.

A static site needs the page in its build output

A static site may generate a separate HTML file for each page. For example, Astro’s routing documentation explains its file-based routes and generated paths.

Ask your assistant to confirm that the production build includes the failing route and that the host serves the correct output directory. A file such as about/index.html is one possible output, not a requirement for every framework.

If the page is missing from the build, fix the page-generation problem. Do not hide it behind a catch-all response that displays unrelated content. For server-rendered sites, inspect the deployed server route instead of assuming a static-file repair applies.

A small example: navigation is not a complete test

In our controlled local browser example, clicking About changed the address to /about and displayed the About heading. Refreshing or opening that address directly returned HTTP 404.

After the example server was changed to serve the app’s entry document for that known route, both tests returned 200 and displayed About without changing the address. An unrelated nonexistent route still returned 404.

This demonstrates one routing mismatch. It is not a test of your hosting account or proof that every refresh error has that cause.

Ask for one bounded repair

On [exact public page address], navigation from the homepage works,
but refresh and a fresh direct visit fail.

First show the failing request and its status. Identify whether this
route needs generated HTML, a browser-app fallback, or server code.
Check the deployed output and existing routing rules.

Propose the smallest fix for this route. Preserve asset requests,
API routes, unrelated pages and intentional not-found behavior.
Show the change and preview it before publishing.

Use our safe update guide for the release itself. Do not change DNS or replace the whole project to guess at a route problem.

Verify the result before calling it fixed

Repeat the menu, refresh and direct-visit tests on the same production URL. Confirm the correct content appears, not just a 200 response or the homepage. Check a second valid page, important assets and an intentionally nonexistent path as well. An SPA should at least show its genuine not-found view for an unknown route, not silently present unrelated content.

Done means the intended page works both through navigation and as a fresh visit. A shared link should not depend on someone visiting your homepage first.

Official sources checked November 11, 2026. The example uses a controlled local browser and server; no Cloudflare account change, cross-browser study or search-indexing outcome is claimed.