# Can a website port scan localhost? How we block it

> Page script can fetch 127.0.0.1 and time the reply. Our old block added switches for popups and gamepads; a PAC file aimed at port 1 is what works.

Source: https://mosaicbrowser.com/blog/web-pages-scanning-localhost

## A web page can knock on 127.0.0.1, and how we close it

Page script can fetch 127.0.0.1 and time the reply. Our old block added switches for popups and gamepads; a PAC file aimed at port 1 is what works.

![A web page can knock on 127.0.0.1, beside a screenshot: creating a profile in Mosaic: a checked proxy, and the hardware and locale drawn to match its IP](https://mosaicbrowser.com/covers/web-pages-scanning-localhost.webp)

Yes, a website can port scan localhost from your browser, within limits. Script on any public page may fire requests at `127.0.0.1`, or at the router at `192.168.1.1`, one port after another, and note which ones answer and how fast the rest fail. It usually can't read what comes back, and it doesn't have to: a listener on a well-known number tells the page what is installed.

For an anti-detect browser that is about as bad as a leak gets. The fingerprint can be flawless and one open port still names the product the profile runs in. Ours did exactly that for a while, and the block we had for it turned out to do nothing at all.

## What a page can learn from 127.0.0.1

You call `fetch('http://127.0.0.1:<port>/', { mode: 'no-cors' })` for each port on a list and time it. Closed ports throw almost at once. An open one hands back an opaque response, which is empty to script but is still a reply, and after a few dozen ports the page has an inventory of the machine.

Mosaic was its own worst case here. The [local REST API](https://mosaicbrowser.com/features/rest-api) used to send `access-control-allow-origin: *`, so a page running inside a profile could call the health route and read `{"ok":true,"name":"mosaic"}`. No inference needed; the product told the page its name.

The server now turns away anything a web page sent. Browsers stamp those requests with a `Sec-Fetch-Site` header that page script has no way to forge, and curl, Node and automation clients leave it off entirely, so a value other than `same-origin` or `none` gets a `403`. That includes the preflight. Our companion extension is the single exception, and it still has to present an API key. All of that fixed what the server says. A page could still see that the port was open.

## Our old block was two unrelated switches

Every profile has a Block local network access switch, on by default, and the editor says it stops "a page port-scanning 127.0.0.1 and your LAN". For a while the only thing behind it was two launch flags, `--block-new-web-contents` and `--restrict-gamepad-access`. The first blocks popups. The second blocks gamepads. The comment above them described a port-scan defence that no line of code implemented, and pages reached `127.0.0.1` as freely as before.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Local first](https://mosaicbrowser.com/features/local-first)

## Chrome's own feature did not hold up

The obvious repair was Chromium's own mechanism. What used to be called Private Network Access is now Local Network Access, and the Chrome team describes it as putting a public site's requests to the local network behind a permission prompt. We switched it on two ways.

First with `BlockInsecurePrivateNetworkRequests`, the name older documentation still gives. That feature name no longer exists in the build, and Chromium accepts an unknown name in silence, so the flag looked like a fix and did nothing. Searching the engine binary for the string is how we found out.

Then with the real one, `LocalNetworkAccessChecks`, warning mode off and the prompt auto-denied. A `no-cors` fetch could still tell an open loopback port from a closed one, so we took both out rather than keep them as insurance. Stock Chrome ships that feature disabled, and turning it on can change what a page reads (`navigator.permissions` among other things). Paying for protection we measured as missing with a fingerprint difference is a bad trade for a browser meant to look ordinary.

## What works: a PAC file that points at a dead port

Chromium asks a proxy auto-config (PAC) file where to send each request before it opens any connection. A profile without a proxy now launches with `--proxy-pac-url` aimed at a small PAC file in its own folder, and that file sends every loopback and private destination to `PROXY 127.0.0.1:1`, where nothing listens. Everything else goes `DIRECT`. It catches `localhost`, `127.*`, `10.*`, `192.168.*`, `172.16.*` through `172.31.*`, `169.254.*`, names ending in `.local`, plus the IPv6 loopback, unique-local and link-local ranges. Only the companion's own host is let through.

Where the file lives turned out to matter. Chromium re-reads a PAC file whenever its network service restarts, and if the file has gone by then (a temp directory cleaned up, say) the browser fails open and every private address is reachable again. So it sits in the profile folder, for as long as the profile does.

It also matches addresses as plain text and never calls `isInNet`, which resolves the hostname before comparing and would put a DNS lookup in front of every request the profile makes. The cost is that a public name resolving to a private address slips past. Scanners work from addresses, though, since they have to enumerate them.

Profiles that do have a proxy skip the PAC file. They already launch with `--proxy-bypass-list=<-loopback>`, which sends loopback through the proxy, so `127.0.0.1` means the proxy's machine and not yours. One residential gateway we measured simply refuses: `464 Connection to the specified target is not permitted`.

## What it does not hide

We hoped the dead port would make an open port and a closed one indistinguishable. It doesn't. Against a test server on an open loopback port, with a closed port next to it:

```
stock Chrome, no PAC   open: resolved in 4ms      closed: TypeError in 1ms
with the PAC file      open: never resolves       closed: TypeError in 1ms

```

Reading is closed off: a response in four milliseconds becomes no response, and the page never sees a byte. Timing is not. The closed port fails before any proxy gets consulted, which is why a dead port and a tarpit that accepts the connection and stalls produced identical rows when we built and measured both. An untouched Chrome on the same machine tells open from closed just as easily, so this does not single out Mosaic, and we list it as a limit instead of calling it solved.

WebRTC is the other way a page can reach toward your network, and [WebRTC local addresses and mDNS](https://mosaicbrowser.com/blog/webrtc-local-address-mdns) covers how Chrome masks local addresses there. Which callers the local API should answer at all, and with what, is in [the anti-detect browser local API guide](https://mosaicbrowser.com/guides/anti-detect-browser-local-api).

## Sources

1. [Chrome for Developers: New permission prompt for Local Network Access](https://developer.chrome.com/blog/local-network-access), read November 3, 2026
2. [WICG: Local Network Access explainer](https://github.com/WICG/local-network-access/blob/main/explainer.md), read November 3, 2026

## Questions

### Can a website port scan my computer from the browser?

It can try. Script on a page can send requests to 127.0.0.1 or a LAN address on many ports and see which ones answer, or how fast they fail. It cannot read a response the server does not allow, but whether a port is open is already information.

### What can a site learn from a port on localhost?

Which software is running. A program listening on a well-known port says what it is, and our own app's API once answered a probe with its product name, which identifies far more precisely than any canvas hash.

### Does Chrome block websites from reaching localhost?

Chrome's Local Network Access work puts requests from public sites to local addresses behind a permission. In our tests, turning on its feature flags with prompts auto-denied still let a no-cors fetch tell an open loopback port from a closed one.

### How does Mosaic block local network access?

With the Block local network access switch on, which is the default, a profile without a proxy gets a proxy auto-config file that points every loopback and private address at a port nothing listens on. A profile with a proxy sends loopback through the proxy instead.

### Can a page still tell an open port from a closed one in Mosaic?

By timing, yes. The request to an open port never completes, while a closed one fails in about a millisecond, and the PAC file cannot change that. An untouched Chrome separates the two just as easily, so it does not single out a Mosaic profile.

## Related

[The .local address in your WebRTC test is Chrome working](https://mosaicbrowser.com/blog/webrtc-local-address-mdns): A random .local name in a WebRTC leak test is Chrome hiding your LAN address. We once switched it off, and the empty result was the louder tell.

[WebRTC leak: when a page finds the address behind your proxy](https://mosaicbrowser.com/glossary/webrtc-leak): A WebRTC leak is a page learning your real IP address through WebRTC's STUN requests, which can go around a proxy or VPN instead of through it.

[Local first: your profiles stay on your computer](https://mosaicbrowser.com/features/local-first): Mosaic has no cloud copy of your profiles. Profiles, cookies and proxies stay on your computer, encrypted on disk, with app lock, daily backups and a trash.

[Anti-detect browser local API: what it is and what to check](https://mosaicbrowser.com/guides/anti-detect-browser-local-api): An anti-detect browser local API is an HTTP server on 127.0.0.1 that creates, starts and stops profiles and hands your script a DevTools endpoint.

[Anti-detect browser REST API: profiles from your scripts](https://mosaicbrowser.com/features/rest-api): Mosaic's anti-detect browser REST API runs on 127.0.0.1 with API keys. Create and start profiles, then attach Puppeteer or Playwright over CDP.







[Chromium's mock keychain, and why we encrypt the store](https://mosaicbrowser.com/blog/mock-keychain-cookies): Chromium's --use-mock-keychain keeps cookie encryption on but uses a password from its own source. We read a live session cookie off disk, then sealed it.

## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
