# How to verify browser traffic goes through a proxy

> To verify browser traffic goes through a proxy, ask the proxy. Count raw TCP accepts from before Chrome starts, then kill the proxy and watch the page fail.

Source: https://mosaicbrowser.com/blog/verify-traffic-at-the-proxy

## Check a proxy at the proxy, not in the browser

To verify browser traffic goes through a proxy, ask the proxy. Count raw TCP accepts from before Chrome starts, then kill the proxy and watch the page fail.

![Ask the proxy what it saw, beside a screenshot: a proxy check result in Mosaic: latency, IP address, ISP, HTTPS support and reputation](https://mosaicbrowser.com/covers/verify-traffic-at-the-proxy.webp)

To verify that browser traffic goes through a proxy, check at the proxy. Run one you control, start counting before the browser exists, count raw TCP accepts rather than parsed requests, and load a page. Then ask the proxy what reached it. A browser that is going around its proxy will still tell you it is using it, so nothing it reports can settle the question.

## Why the browser is the wrong witness

The usual check is a what-is-my-IP page. If it shows the proxy's IP, the proxy works. That is true for exactly one request: the one that fetched that page. It does not cover the DNS lookups the browser made first, the connections Chrome opens on its own at startup, an extension's traffic, or WebRTC, which can send UDP that an HTTP proxy never carries. And the answer is shown to you by the browser under test.

A proxy is the other end of the wire. It records what reached it and cannot be argued out of it. So when we wrote the plumbing check for Mosaic, `scripts/check-proxy.mjs`, the rule in its header was that every assertion is "observed at the proxy, not reported by the browser, because a browser that is bypassing its proxy will happily tell you it is not."

## There are two ways to be wrong

Proxy checks tend to mix two questions, and they fail differently.

The first is identity: does the profile describe a person at the IP? Timezone, language and geolocation should follow the IP's country. We test that offline, against synthetic IPs in Chicago, Berlin, Tokyo, São Paulo, London and Sydney. A live residential IP moves between runs, so a pass against one would prove nothing about our code, and a failure might be the provider's.

The second is plumbing: does the traffic go through the proxy, and only through it? That needs a real proxy and a real browser, and it is the one a what-is-my-IP page pretends to answer.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Checked before every launch](https://mosaicbrowser.com/features/proxy-check-before-launch)

## How to verify browser traffic goes through the proxy

1. Run a proxy of your own on loopback that really forwards traffic. It has to forward: a proxy that refuses every CONNECT request makes every page fail, and "nothing loaded" then means the same thing whether the route was right or not.
2. Count raw TCP accepts, and log every event with a timestamp. A parser that chokes on a request writes no log line. Our first home-made proxy parsed CONNECT by hand with no error handling, and its zero meant nothing; an `uncaughtException` handler and an accept counter are what made a zero believable.
3. Start the count before the browser process starts. This is the step we got wrong for four hours, measuring launches that showed 1, 0 and 0 CONNECTs to the site under test and concluding that the browser was bypassing the proxy. It was not. A restored tab had preconnected during startup, before our counter was reset, and the page rode that connection. Counted from before the launch, every run showed the host, with 9 TCP accepts and 6 to 8 CONNECTs per launch ([Chrome opens connections before your test starts](https://mosaicbrowser.com/blog/chrome-preconnects-before-you-measure) has the whole four hours).
4. Load a page, then read what the proxy saw. At least one connection must have arrived, and one of them must name the host you opened. Traffic to some other host proves the proxy is in use, not that the page went through it.
5. Check that every CONNECT target is a hostname. `CONNECT 93.184.216.34:443` means your machine looked the name up itself ([a raw-IP CONNECT](https://mosaicbrowser.com/blog/a-numeric-connect-means-dns-leaked) covers what that leak is).
6. Read a value the origin computed, not the URL. A Chromium error page quotes the URL it failed to load, so "the page contains my test token" proves the browser tried to go there, not that anything was fetched. An echo service's report of the address it saw is a value only a real fetch can bring back.
7. Kill the proxy and try again. Point the browser at a port where nothing listens and load the same page. An error page is the pass. A page that loads means the browser fell back to a direct connection, and that one looks, from outside, exactly like everything working. [When Chrome falls back to direct](https://mosaicbrowser.com/blog/chrome-proxy-fallback-to-direct) lists the settings that allow it.

## What our check runs

`check-proxy.mjs` runs the core of those steps through Mosaic's own API, in three scenarios. Its proxy really forwards, records every request and CONNECT it is asked for, and is listening before the browser starts. It does not count raw accepts; that was the instrument for the four-hour hunt. It creates a profile pointed at its recording proxy on loopback, starts it, opens `https://example.com/`, waits nine seconds and reads the proxy's record.

It runs once with no credentials and once with a user and password the proxy insists on, because the two take different routes. A plain proxy goes straight to Chrome's `--proxy-server` switch. For an authenticated one, Mosaic logs in to the proxy for Chrome, on your computer, and a fault in that step is the kind that fails open into no proxy at all. With credentials, the check also decodes the `Proxy-Authorization` header and requires it to match what was configured.

The third scenario points a profile at port 47119, where nothing is listening, chosen high and odd so it does not collide with anything real, and fails if `example.com` loads.

The profiles are created for the run and deleted afterwards. The proxy is deliberately local, not a provider's: a check that depends on somebody else's uptime is a check that eventually gets ignored.

## What a launch in Mosaic does about it

The check is for our code. For a profile you use, the launch itself is the gate: Mosaic does not open a browser behind a proxy that has not answered and connected, and the refusal says which one failed. With a proxy attached, WebRTC is stopped from sending UDP around it by default. [The check before every launch](https://mosaicbrowser.com/features/proxy-check-before-launch) is the shipped half of what this script tests, and a proxy you are about to buy or attach can be tested by hand with the steps in [how to check a proxy before you use it](https://mosaicbrowser.com/guides/how-to-check-a-proxy-before-you-use-it).

## Questions

### Is a what-is-my-IP page enough to prove the browser uses the proxy?

It proves that one request, the one that loaded the page, left from the proxy's IP. It says nothing about DNS lookups, preconnects, extension traffic or WebRTC, and it is reported by the browser you are testing.

### Why count TCP connections instead of reading the proxy log?

A log line is written after the proxy has parsed a request. A connection the parser choked on, or one that never sent a full CONNECT, leaves no line at all. A raw accept count misses nothing that reached the port.

### When should the count start?

Before the browser process exists. Chrome opens connections during startup, including a preconnect for a restored tab, so a counter reset after launch can miss the very connection the page then uses.

### How do I check that a dead proxy fails closed?

Point the browser at a port where nothing is listening and load a page. The right result is an error page. A page that loads means the browser went around the proxy, which is the most dangerous failure because it looks like everything working.

## Related

[Chrome opens connections before your test starts](https://mosaicbrowser.com/blog/chrome-preconnects-before-you-measure): We counted 1, 0 and 0 CONNECTs in three launches and thought Chrome was bypassing the proxy for HTTPS. Our counter was reset after Chrome had started.

[A CONNECT to a raw IP means your machine resolved the name](https://mosaicbrowser.com/blog/a-numeric-connect-means-dns-leaked): To check if DNS goes through your proxy, read what the proxy is asked for. CONNECT example.com:443 means it resolved the name; a raw IP means you did.

[When Chrome falls back to a direct connection](https://mosaicbrowser.com/blog/chrome-proxy-fallback-to-direct): Chrome falls back to a direct connection only when DIRECT is in its proxy list or a PAC file fails to load. A dead proxy should break the page.

[Check the proxy before launching a browser profile, every time](https://mosaicbrowser.com/features/proxy-check-before-launch): Mosaic checks the proxy before launching a browser profile: it must answer and carry HTTPS. If it does not, nothing opens and the error names the proxy.

[How to check a proxy before you use it](https://mosaicbrowser.com/guides/how-to-check-a-proxy-before-you-use-it): Check that a proxy answers and connects, where its IP really is, whether the address is residential or blocklisted, and that the browser stays behind it.







[An empty WebRTC section is the right answer](https://mosaicbrowser.com/blog/ipleak-webrtc-no-ip): On ipleak.net, an empty WebRTC section behind a proxy means no candidate went around it. Our own script once called that a leak, reading the wrong line.

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