Free auditStart free
GuideError · CDN and hosting errors

Firebase Hosting 404

Fix a Firebase Hosting 404: check the public directory, response priority order, rewrites, cleanUrls and a custom 404.html, with firebase.json you can copy.

3 min
read
4
sources
Oct 29, 2026
updated
Scaplet Editorial Team
author
In one line

Firebase Hosting returns 404 when no redirect, static file or rewrite matches the path. The usual causes are a wrong public directory, a file missing from the deploy, cleanUrls or trailingSlash URL differences, or no rewrite for a single-page app. Check firebase.json against the documented priority order, then redeploy.

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
01Priority order of Hosting responses

How Firebase Hosting decides to return a 404

When settings overlap, Hosting picks its response in a fixed order. A 404 is what you get when the list runs out.
Order

1

Checked
Reserved namespaces starting with /__/*
If it matches
Handled by Hosting
Order

2

Checked
Configured redirects
If it matches
Redirect sent
Order

3

Checked
Exact-match static content
If it matches
The file is served
Order

4

Checked
Configured rewrites
If it matches
Rewritten response
Order

5

Checked
Custom 404 page
If it matches
Your 404.html
Order

6

Checked
Default 404 page
If it matches
Firebase's default

Within redirects and rewrites, the first rule with a matching URL pattern wins, and redirects still beat rewrites. So a 404 on a path you expected to work means no file at that path was deployed and no earlier rule caught it.

03Check it

Serve a real 404 page

To show your own page for missing URLs, create 404.html in the public directory. Hosting displays it when a browser triggers a 404 on your domain or subdomain. You can also set cache headers on it; Firebase's configuration reference shows an example that caches 404 pages for 5 minutes. For the same problem on repository-based static hosting, see this 404 guide.
Check what the live site returns, and preview locally
curl -sI https://YOUR-SITE.web.app/does-not-exist | head -n 1
firebase serve --only hosting
04How it works

Verify and avoid SEO fallout

Google does not index URLs that return 4xx and removes indexed ones, which is the right outcome for deleted pages and the wrong one for pages that moved. For moved pages add a redirects entry; see custom 404 missing and single-page app routing.

  1. 01

    Request the missing URL

    Run the curl above. A 404 with your page is correct for URLs that should not exist; a 200 on junk URLs means a catch-all rewrite.

  2. 02

    Request the one that should work

    Check it with curl -sI. A 404 means the file was not deployed or a pattern did not match.

  3. 03

    Redeploy

    Run firebase deploy --only hosting, then retest in a private window to skip cached copies.

Sources · 4

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • google.com
  1. 01Firebase: Configure Hosting behaviorfirebase.google.com · checked 2026-11-01
  2. 02Firebase: CLI referencefirebase.google.com · checked 2026-11-01
  3. 03Firebase: Get started with Firebase Hostingfirebase.google.com · checked 2026-11-01
  4. 04How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Questions

Asked a lot.

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

01Why does Firebase Hosting return 404?

No redirect, static file or rewrite matched the path. Check that public points at your build output, that the file was deployed and not ignored, and that cleanUrls, trailingSlash and rewrites match the URL you request.

02How do I make a custom 404 page on Firebase Hosting?

Create 404.html in your public directory and redeploy. Hosting serves its content when a browser triggers a 404 on your domain.

03Why do deep links in my SPA return 404 on refresh?

There is no file at that path. Add a catch-all rewrite to /index.html, which serves index.html for files or directories that do not exist. Then make the app show a not-found view for unknown routes.

04Which wins on Firebase Hosting, a rewrite or a static file?

The static file. Exact-match static content is checked before rewrites, and redirects are checked before both.

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