Firefox Local Mode: Goodbye, localhost?
Double-click an index.html on your machine and a lot of the web stops working.
The service worker won’t register, and the fetch() for the JSON file sitting right next to it fails.
Read Free for non-members.
So you do the usual thing and start a server. Firefox Local Mode, new in Firefox 153, is the first thing I’ve seen that makes that step optional.
Why I keep a terminal open for a folder of static files
My reflex here is npx serve.
Inside a real project it’s the Vite dev server, and for a quick HTML experiment I’ll sometimes just click “Go Live” in VS Code’s Live Server extension.
npx serve .
# Or use live server
npx serve .
# Or use live server
None of these are hard. It’s just a bit silly that showing a folder of static files in a browser needs a running process, a port, and one more terminal tab I’ll forget to close.
Here’s a real-world example:
Imagine you’re testing a small product page with an index.html, a products.json file, and some JavaScript that loads the product details.
You don’t need a backend. You don’t need a database. You just want to see whether the page displays the right product cards.
But if your page uses fetch('./products.json'), opening the HTML file directly can cause the request to fail. Now you’re starting a server just to test a page that doesn’t need one.
That’s the kind of small annoyance Firefox Local Mode tries to remove.
The reason is the file:// scheme. A page opened straight from disk doesn’t get a normal web origin.
In my Firefox, location.origin on a file:// page comes back as null, and anything that cares about origins gets cautious from there.
I assumed the bigger problem would be the secure context rule, where APIs like the async Clipboard API, camera access and WebGPU only run on HTTPS or localhost.
WebGPU is the one that matters if you’ve tried running an AI model in a browser tab. 👇
I Ran an AI Model in a Browser Tab
I wanted to run AI in the browser with no backend. So I built it. Live demo and source code inside.
But Firefox reported isSecureContext as true on my file:// page, which honestly surprised me. So in Firefox, at least, the null origin causes most of the trouble.
Service workers are stricter than both. Firefox rejects them on file:// with a very direct error: “Script URL’s scheme is not ‘http’ or ‘https’.”
What Firefox Local Mode does
Firefox Local Mode is a DevTools feature that maps a folder on your disk to a custom https:// origin. Firefox serves the files itself, so there’s no server process and no port.
According to Mozilla’s documentation, you get three things out of it:
- Secure-context-only Web APIs become testable on local files.
- Every mapping gets its own origin, so each project has dedicated storage and cookies.
- Mappings only work inside Firefox. Other programs and other devices on your network can’t reach them.
The last one is a real difference from npx serve, which happily prints a network address alongside the local one. Local Mode has nothing listening on a port for anything else to find.
I tried it on a small demo folder in Firefox Developer Edition 159: an index.html, a data.json next to it, and a Web Worker script. That isn’t a real project yet, so read my results as one folder on one Windows machine.
If you’d rather watch the whole test than read it, here it is in a bit over two minutes:
How to set up a mapping
Open DevTools and go to its Settings panel. A mapping has two parts, an origin and a local folder. Mozilla’s own example maps https://firefox.localhost to /home/alex/app.
There’s a quicker route too. Open any file:// URL while DevTools is open, and Firefox shows a notification with two buttons.
“Try it” creates a temporary mapping that disappears when you close DevTools or Firefox. “Add To Settings” saves a permanent one.
I like that split more than I expected to. Most of the local HTML files I open are throwaway (a bug repro, a CSS idea, a snippet from a Stack Overflow answer I don’t fully trust yet) and “Try it” covers those without leaving a pile of saved config behind me.
It’s the same itch that made me stop cloning whole repos for one file 👇
I Was Tired of Cloning Repos for One File
What if you could browse and download only what you need?
If you’d rather edit config directly, every mapping lives in about:config as numbered preferences. Two projects would look something like this:
devtools.local-mode.mappings.0.origin firefox.localhost
devtools.local-mode.mappings.0.path /home/alex/app
devtools.local-mode.mappings.1.origin demo.localhost
devtools.local-mode.mappings.1.path /home/alex/demo
devtools.local-mode.mappings.1.disabled true
devtools.local-mode.mappings.0.origin firefox.localhost
devtools.local-mode.mappings.0.path /home/alex/app
devtools.local-mode.mappings.1.origin demo.localhost
devtools.local-mode.mappings.1.path /home/alex/demo
devtools.local-mode.mappings.1.disabled true
The disabled flag is optional. It’s handy for parking a mapping without deleting it.
What worked when I tried it, and what didn’t
After clicking “Try it”, my demo page reloaded at [https://firefox.localhost/index.html](https://firefox.localhost/index.html.).
The origin was a real https://firefox.localhost and isSecureContext was true.
fetch('data.json') loaded the file sitting next to it, and the Web Worker started and posted its message back, with no server running anywhere.
Then I added a service worker, and it failed:
ServiceWorker script at https://firefox.localhost/sw.js for scope
https://firefox.localhost/ encountered an error during installation.
ServiceWorker script at https://firefox.localhost/sw.js for scope
https://firefox.localhost/ encountered an error during installation.
My first guess was that my sw.js was broken. It was one line.
So I ran a tiny listener on 127.0.0.1:443 and reloaded the page. Firefox tried to connect to that real port twenty times.
I reloaded twice more and got twenty both times, which is too tidy to be noise.
The page’s own fetch() and the worker had loaded fine, so as far as I can tell the service worker’s script request was going past Local Mode and out to a port where nothing was serving it.
My best guess is that Local Mode intercepts requests made by the tab, and a service worker’s script fetch doesn’t count as one of those. Mozilla’s docs don’t mention service workers either way, and I couldn’t find a Bugzilla bug about it, so I might be missing a setting. On Firefox 159, though, I wouldn’t count on service workers working under Local Mode.
This matters if you’re building a Progressive Web App (PWA). A service worker might handle offline pages, cache files, or let an app reopen when the network disappears.
Each project gets its own origin
The headline feature is “no server”, but I think the separate origin per project is the bigger deal.
A localhost origin is scheme, host and port. Vite starts every project on localhost:5173 by default, so project A’s localStorage, cookies and (the fun one) its registered service worker are all still sitting on that origin when project B starts on the same port.
If you’ve ever opened a fresh project and been served a cached page from a completely different one, an old service worker is the usual suspect, and you end up in DevTools → Application unregistering it by hand.
With Local Mode, https://shop.localhost and https://blog.localhost are different origins, each with its own storage and cookies, so nothing carries over from one project to the next.
I’d probably use it for that isolation alone, even on folders where a server works fine.
But There’s a Catch: DevTools Has to Stay Open
Mappings only work while DevTools is open. Close the panel and the page loses its mapping.
My guess is this is deliberate, to keep Local Mode a developer tool and not a general browsing feature. It will still trip people up the first time, probably by reloading in a new window without DevTools and wondering why everything just broke.
Do you still need a localhost server?
For a lot of work, yes. Local Mode loads files from disk; it doesn’t run anything on a server for you.
- Anything with a backend, API routes or server-side rendering still needs a server.
- Vite’s hot module replacement, TypeScript and JSX transforms, and resolving bare imports like
import 'react'are all dev-server jobs. Local Mode doesn’t do any of that. - It’s Firefox only. Checking the same page in Chrome or Safari still means starting your usual server.
- Service workers didn’t work in my test, so PWA and offline work stays on a localhost server for now.
It fits the smaller stuff: plain HTML/CSS/JS folders, bug repros, pages that fetch() their own JSON or start a Web Worker, and demos you want to open without remembering which port they were on.
I don’t know yet whether it’ll replace npx serve for me. For the small static folders I currently spin up a server for, it might.
Who should try it
If you work on static files that need a real origin and you already use Firefox, set up one mapping and see whether you miss the terminal tab.
Use .localhost names per project so storage stays separate. Keep your dev server for anything with a build step, a backend, a service worker, or a second browser.
Questions I Had While Testing It (FAQs)
- Why do some browser APIs fail on
file://?
A page opened from disk gets anullorigin, so Firefox blocks things likefetch()of a file in the same folder (it calls it a CORS error) and loading a Web Worker script. Service workers refuse any scheme other thanhttporhttps. Firefox Local Mode gives the files a realhttps://origin, which fixed fetch and the worker in my test, but not the service worker. - How do I test a service worker locally without HTTPS?
Run any plain server onlocalhost. Browsers already treathttp://localhostas a secure context, so you don’t need a certificate. Firefox Local Mode didn’t help here in my test: on Firefox 159 the service worker failed to install because its script request bypassed the mapping. - Do I still need a localhost server for frontend testing?
For framework projects, anything with a backend, and testing in other browsers, yes. For plain static files in Firefox, Local Mode can cover it.
npx serve is still in my shell history, and after that service-worker test, it’s definitely staying.
But the next time a folder of static files just needs a real origin, I’m trying Firefox Local Mode before I open another terminal.
Sometimes the best developer tool isn’t the one that replaces your workflow. It’s the one that removes a few unnecessary steps from it.
Thanks for reading 🙏
More from Tushar Kanjariya
Connect with me 👇
Tushar Kanjariya | Linktree
Full Stack Developer who occasionally writes


