Will It Host? / Firefox

Can you run a Minecraft server in Firefox?

It hosted#12 of 18 by difficulty

Yes. The process listening on port 25565 is Firefox, with no extension, no mod and no recompile. A tab opens showing the world as a live web page, every player who joins gets their own tab, and every block placed becomes a bookmark on the toolbar pointing at that block's wiki page.

verdict
It hosted
A vanilla Minecraft client connected and played on it.
difficulty
#12 of 18
Ranked against everything else in the series, hardest first.
built withJavaScript
protocolMinecraft 1.8.9
read the source on github β†’

How it works

Firefox has a privileged JavaScript console with access to its own internals, and one of those internals is nsIServerSocket, the same interface the browser's own devtools server listens on. Paste the script into the Browser Toolbox and it binds port 25565 in Firefox's parent process. Reads go through nsIAsyncInputStream.asyncWait so the browser's main thread never blocks, and the map page is generated as HTML, written to the temp directory with IOUtils and reloaded once a second.

The part that nearly stopped it

The buttons on the map page. A file page runs in a content process and cannot call into chrome code, so a Stop button had no way to reach the socket it was meant to close.

What got it over the line

Going through the URL. The buttons set location.hash, the chrome side polls the tab's URI four times a second, reads the command and navigates back to the base URL, which means clicking a link in a web page closes the server socket. Everything else is arrays: no Buffer and no struct, so VarInts, big-endian ints, IEEE754 doubles and the packed block position are built as plain JavaScript arrays, with BigInt for the position because 1.8 packs three coordinates into 64 bits and a JavaScript number cannot hold it.

What it cannot do

Minecraft 1.8.9, the same target as the rest of the series. It needs devtools.chrome.enabled and devtools.debugger.remote-enabled set in about:config and a restart, and there are no mobs, no physics, no inventory persistence and no world saving.

Why this is possible at all

A Minecraft Java server is a smaller thing than its reputation suggests. It is a socket, a packet codec and a game loop. The client opens one TCP connection, sends a handshake naming its protocol version, moves through login into the play state, and from then on both sides exchange length-prefixed packets describing chunks, entities and movement. None of that needs a game engine. It needs something that can hold a socket open and put the right bytes on it in the right order, which is why Firefox can be made to do it. In every episode the host is the hard part.

Every build in this series targets Minecraft 1.8.9 for one specific reason. In 1.8 a chunk is a flat byte array you can send uncompressed. From 1.9 onward chunk data is palette-encoded into bit-packed longs and the connection expects zlib, which is not something you can hand-write in VBA. 1.8.9 is the last release where the whole protocol is within reach of a scripting runtime that was never meant for it.

We have written both halves of that up properly: how the Minecraft server protocol works covers the wire format, and what a Minecraft server actually needs to run covers the four things a real one cannot do without.

Questions

Can Firefox run a Minecraft server?

Yes, with nothing installed. Firefox's Browser Toolbox runs privileged JavaScript in the parent process, and that code can create an nsIServerSocket and bind port 25565. It is not the F12 devtools, which run against a web page: this is Ctrl+Alt+Shift+I with devtools.chrome.enabled turned on. The full source is on GitHub.

Why does it open a tab for every player?

Because it can. The chrome side can open and close tabs, so a tab appears when someone joins and closes when they leave, alongside the map page that redraws itself every second. Placed blocks go on the bookmarks toolbar as links to the Minecraft wiki, so the bookmarks are clickable.

The rest of the series

See the full Will It Host? board β†’

Or just host it properly

Firefox is not where your survival world should live. AMD Ryzen 9700X, hard-reserved RAM, NVMe, online in under a minute with a free address, DDoS protection and a 7-day money-back guarantee.