# 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.

Canonical: https://scaplet.com/errors/cdn/firebase-hosting-404

Guide Error · CDN and hosting errors

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Ffirebase-hosting-404%20(%22Firebase%20Hosting%20404%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%2Fcdn%2Ffirebase-hosting-404%20(%22Firebase%20Hosting%20404%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%2Fcdn%2Ffirebase-hosting-404%20(%22Firebase%20Hosting%20404%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%2Fcdn%2Ffirebase-hosting-404%20(%22Firebase%20Hosting%20404%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 4 parts, 3 minutes.

1. [How Firebase Hosting decides to return a 404 01](#how-firebase-hosting-decides-to-return-a-404)
2. [Why the file is not there 02](#why-the-file-is-not-there)
3. [Serve a real 404 page 03](#serve-a-real-404-page)
4. [Verify and avoid SEO fallout 04](#verify-and-avoid-seo-fallout)

_01_Priority 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.

_02_Causes, checks and fixes

## Why the file is not there

Cause

### `public` points at the wrong folder

Check

`hosting.public` in `firebase.json`, e.g. `dist/app`

Fix

Set it to your build output folder, which must exist in the project directory

Cause

### The build output was not rebuilt before deploy

Check

Whether the file is in the folder you set as `public`

Fix

Run your build, then `firebase deploy --only hosting`

Cause

### The file was excluded by `ignore`

Check

The default ignore list: `firebase.json`, dotfiles and `node_modules` (exact globs are in the config sample below)

Fix

Files with a leading period are ignored by default, so rename them or adjust `ignore`

Cause

### `cleanUrls` changed the URL

Check

With `cleanUrls: true` the `.html` extension is dropped, and a request that includes `.html` is 301 redirected to the clean path

Fix

Link to the clean URL

Cause

### `trailingSlash` mismatch

Check

Unspecified: trailing slashes only for directory index files such as `about/index.html`

Fix

Set `trailingSlash` to true or false to make one form canonical

Cause

### A single-page app route with no rewrite

Check

A deep link such as `/app/settings` has no file

Fix

Add a catch-all rewrite to `/index.html`

firebase.json: single-page app with the documented catch-all rewrite

```
{ "hosting": { "public": "dist/app", "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } }
```

firebase.json: clean URLs and no trailing slash

```
{ "hosting": { "public": "public", "cleanUrls": true, "trailingSlash": false } }
```

Note that `trailingSlash` does not affect rewrites to dynamic content served by Cloud Functions or Cloud Run.

_03_Check 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](/errors/cdn/github-pages-404).

**The SPA rewrite turns every miss into a 200**A catch-all rewrite serves `index.html` for files or directories that do not exist, so a missing URL answers 200, not 404. Google says content that suggests an error can be reported in [Search Console](/glossary/google-search-console) as a soft 404. Have the app render a not-found view and, where you can, serve a real 404 page for unknown routes. See [soft 404](/glossary/soft-404).

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
```

_04_How 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. 01 [Firebase: Configure Hosting behavior](https://firebase.google.com/docs/hosting/full-config) firebase.google.com · checked 2026-11-01
2. 02 [Firebase: CLI reference](https://firebase.google.com/docs/cli) firebase.google.com · checked 2026-11-01
3. 03 [Firebase: Get started with Firebase Hosting](https://firebase.google.com/docs/hosting/quickstart) firebase.google.com · checked 2026-11-01
4. 04 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-11-01

Questions

## Asked a lot.

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

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

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

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

_04_ Which 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.

## Keep learning

[All errors](/errors)

[Learn GitHub Pages 404 Not Found CDN and hosting errors](/errors/cdn/github-pages-404) [Related Soft 404 Crawling](/glossary/soft-404) [Read next Cloudflare Pages 404 Not Found CDN and hosting errors](/errors/cdn/cloudflare-pages-404) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 404 errors
[AWS Amplify 404 Not Found](/errors/cdn/amplify-404) [Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404) [CloudFront 404 Not Found](/errors/cdn/cloudfront-404) [GitHub Pages 404 Not Found](/errors/cdn/github-pages-404) [404 Not Found](/errors/http/404)

More in CDN and hosting errors
[AWS EC2: Connection timed out](/errors/cdn/aws-ec2-connection-timed-out) [AWS Lambda 502 Bad Gateway](/errors/cdn/aws-lambda-502) [AWS Lambda timeout](/errors/cdn/lambda-timeout) [Azure Front Door 502](/errors/cdn/azure-front-door-502) [Cloud Run 503 error](/errors/cdn/cloud-run-503) [Cloudflare 504 Gateway Timeout](/errors/cdn/cloudflare-504) [Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404) [Cloudflare too many redirects (ERR_TOO_MANY_REDIRECTS)](/errors/cdn/cloudflare-too-many-redirects) [Cloudflare verify you are human loop](/errors/cdn/cloudflare-verify-you-are-human-loop) [CloudFront 400: Bad Request](/errors/cdn/cloudfront-400) [CloudFront 404 Not Found](/errors/cdn/cloudfront-404) [CloudFront 503: Service Unavailable](/errors/cdn/cloudfront-503) [Firebase Hosting 404](/errors/cdn/firebase-hosting-404) [GitHub Pages 404 Not Found](/errors/cdn/github-pages-404) [Google Cloud 502 Bad Gateway](/errors/cdn/google-cloud-502) [Heroku 503 Service Unavailable](/errors/cdn/heroku-503) [Heroku H10: App crashed](/errors/cdn/heroku-h10-app-crashed) [Heroku H12: Request timeout](/errors/cdn/heroku-h12-request-timeout) [Heroku H13: Connection closed without response](/errors/cdn/heroku-h13) [Heroku H14: No web processes running](/errors/cdn/heroku-h14) [Netlify build failed](/errors/cdn/netlify-build-failed) [Netlify function timeout](/errors/cdn/netlify-function-timeout) [Render 502 Bad Gateway](/errors/cdn/render-502) [S3 Access Denied (403 Forbidden)](/errors/cdn/s3-access-denied)

Terms on this page
[Soft 404](/glossary/soft-404) [Google Search Console](/glossary/google-search-console)

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
