1
- Checked
- Reserved namespaces starting with
/__/* - If it matches
- Handled by Hosting
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.
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.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
/__/*redirectsrewrites404.htmlWithin 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.
public points at the wrong folderhosting.public in firebase.json, e.g. dist/apppublicfirebase deploy --only hostingignorefirebase.json, dotfiles and node_modules (exact globs are in the config sample below)ignorecleanUrls changed the URLcleanUrls: true the .html extension is dropped, and a request that includes .html is 301 redirected to the clean pathtrailingSlash mismatchabout/index.htmltrailingSlash to true or false to make one form canonical/app/settings has no file/index.html{
"hosting": {
"public": "dist/app",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}{
"hosting": {
"public": "public",
"cleanUrls": true,
"trailingSlash": false
}
}Note that trailingSlash does not affect rewrites to dynamic content served by Cloud Functions or Cloud Run.
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.curl -sI https://YOUR-SITE.web.app/does-not-exist | head -n 1
firebase serve --only hostingGoogle 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.
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.
Check it with curl -sI. A 404 means the file was not deployed or a pattern did not match.
Run firebase deploy --only hosting, then retest in a private window to skip cached copies.
4 questions people ask next, answered from the sources on this page.
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.
Create 404.html in your public directory and redeploy. Hosting serves its content when a browser triggers a 404 on your domain.
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.
The static file. Exact-match static content is checked before rewrites, and redirects are checked before both.
Run the free audit, then approve the fixes. Every change can be undone.