Back to Knowledge Hub
Network

Puppeteer Proxy: Configure It and Verify the Exit

Set a proxy through the launch argument Chromium actually reads, then prove the exit from an owned endpoint instead of trusting a successful page load.

BotBrowser Team

Puppeteer Proxy: Configure It and Verify the Exit
Documentation

Want the structured docs for Network?

This article lives in the editorial library. For step-by-step setup, reference material, and ongoing updates, jump into the docs section.

Four launch shapes compared by what the browser receives and what the owned endpoint observes.

Puppeteer has no proxy option in LaunchOptions. The browser receives its proxy from a Chromium command-line switch, --proxy-server=..., passed through args. A script that sets an object property named proxy starts a normal direct browser: nothing rejects it, so the run looks healthy while the destination still sees the host address. Verifying the exit from an endpoint you own is the only step that separates "configured" from "in effect". BotBrowser documents proxy inputs for its own launcher and profile, but it does not accept Puppeteer's launch options for you and does not change which switch Chromium reads.

Two facts explain most failed runs. First, the proxy is a browser-level process switch, not a page or request object, so it must be present at launch. Second, Chrome's SOCKS5 path already resolves destination names on the proxy side and supports no SOCKS5 authentication method; socks5h:// is not a scheme its URI parser recognises, so it cannot add a capability the browser lacks. Both are documented behaviours, not assumptions about your provider.

TL;DR

  • Pass args: ['--proxy-server=http://host:port'] at launch. launch({ proxy: ... }) is not a documented Puppeteer option and does nothing.
  • Verify the exit from an endpoint you control. A rendered page, or a 200, does not prove which address or resolver carried the request.
  • Chrome resolves SOCKS5 destination names proxy-side by design, socks5h:// is not a scheme its URI parser recognises, and Chrome's SOCKS5 path supports no authentication methods; an adapter is the usual answer when credentials are required.
  • Keep the proxy scheme separate from the destination scheme. An http:// proxy can still carry an https:// destination through CONNECT.
  • Check the browser's own proxy resolution before blaming the provider: request interception, a direct-route exclusion list, or a service worker can each remove a request from the expected path.
  • BotBrowser can keep a declared profile and network route consistent for repeatable checks; it does not supply the proxy, authenticate it or guarantee an origin's response.

Contents

Which launch input Chromium actually reads

The Puppeteer LaunchOptions reference lists args, executablePath, channel, ignoreDefaultArgs, timeout and similar fields. It has no proxy member. The option that reaches the browser is the Chromium switch documented in the Chromium proxy documentation: --proxy-server=XXX, plus an optional direct-route exclusion list.

import puppeteer from 'puppeteer-core';

const browser = await puppeteer.launch({
  executablePath: process.env.CHROME_PATH,
  args: ['--proxy-server=http://127.0.0.1:3128'],
});

That switch changes the browser process. A page cannot set it, a page.evaluate call cannot add it, and an object such as { proxy: { server } } is silently ignored because Puppeteer never reads it. If a test framework offers a proxy option, check what it forwards; treat the resulting Chromium argument as the thing to confirm.

The scheme in --proxy-server describes the connection to the proxy, not the destination. --proxy-server=http://127.0.0.1:3128 means an HTTP proxy on loopback, and an https:// page still travels through that proxy using CONNECT. Writing --proxy-server=https://... requests TLS to the proxy itself, which is a different configuration and fails when the proxy does not accept TLS. Record both schemes in the failure log; the fix for an HTTPS destination is usually not an HTTPS proxy.

Direct-route exclusions deserve the same scrutiny. The exclusion list accepts patterns for destinations that should connect without the proxy, and Chromium applies implicit loopback exclusions of its own. A short test on 127.0.0.1 can therefore succeed even while every external request uses the proxy, or the reverse. Assert on the counter at the proxy and the address at the endpoint, not on a page title.

Prove the exit from an endpoint you own

A proxy test needs an observer, not a screenshot. Use an owned HTTP endpoint that returns the address and resolver it saw, and a proxy that counts forwarded requests. Then compare four records: the address the endpoint observed, the request count at the proxy, the absence of a direct connection, and the browser's own error if the request failed.

RecordWhere it comes fromWhat a mismatch means
Endpoint-observed addressOwned server response bodyThe request reached the observer by some path, not necessarily the intended one
Proxy forward counterProxy access logZero forwards with a 200 means the request bypassed the proxy
Direct-connection counterSecond listener on the originA nonzero direct count contradicts the proxy claim
Browser request eventPuppeteer request interception, observation onlyAn intercepted request can be fulfilled by the test and never reach the proxy

The last row catches a common false positive. If the script installs a request handler and fulfils a response, the page can render without any connection to the proxy or the origin. Disable interception for the verification run, or count it as a separate synthetic path.

Four failure shapes cover most of the reports that reach a support queue. Each one leaves a different counter fingerprint, so the first step is to decide which shape you have rather than to change the launch call again.

Symptom in the testCounter fingerprintMost likely cause
Page loads, endpoint shows the host addressProxy forwards 0, direct listener 1The proxy was never set, or a proxy object was ignored
Proxy rejects with 407Proxy forwards 0, proxy challenges countedProxy credentials are required and the browser has none
Request hangs, then times outProxy forwards 1, no endpoint responseThe upstream tunnel failed after the proxy accepted it
Endpoint sees a different exit than expectedProxy forwards 1, endpoint address differsA different upstream route or provider session served the request

The first row is the failure this page exists to prevent. A property named proxy in a launch object produces no warning, no error and no request-level evidence; the browser simply starts without the switch. The second row is the authentication boundary, which belongs to the Puppeteer proxy authentication cases rather than to the launch shape. Moving the same launch-argument and route separation to Playwright is covered by the Playwright proxy configuration comparison. The third row is a provider or destination problem, and the fourth is an upstream routing question; neither is fixed by changing Puppeteer code.

const context = browser.defaultBrowserContext();
const page = await browser.newPage();
const response = await page.goto(process.env.OWNED_ECHO_URL, {
  waitUntil: 'domcontentloaded',
});
if (!response || response.status() !== 200) {
  throw new Error(`echo endpoint unreachable: ${response?.status() ?? 'no response'}`);
}
const observed = JSON.parse(await response.text());
if (observed.address !== process.env.EXPECTED_PROXY_EXIT) {
  throw new Error(`exit mismatch: saw ${observed.address}, expected the proxy exit`);
}

The snippet is a shape, not a provider test. It fails when the endpoint returns a direct address, when the response is a login or error page, and when the endpoint is unreachable. It does not prove the provider's upstream route, and it says nothing about traffic the page did not send during that request.

Keep the verification endpoint free of application logic. A page that redirects, sets cookies or requires a session adds variables that have nothing to do with the proxy. Serve a plain JSON document from a listener that records the source address and the requested host, and run the check before any application navigation. If the endpoint must sit behind the same reverse proxy as the application, record that as part of the path rather than treating it as a neutral observer.

Run the check twice with different expected values to prove the assertion can fail. First point EXPECTED_PROXY_EXIT at the address the endpoint actually reports; the run should pass. Then point it at a different address in the same reserved documentation range; the same script should throw the exit-mismatch error. A check that has never failed is indistinguishable from a check that never ran, which is exactly the state a silently ignored launch option produces.

SOCKS5, DNS and the authentication boundary

The Chromium proxy documentation is explicit about both limits. For SOCKSv5, name resolution is performed on the proxy side, so there is no client-side DNS step to move with a different scheme spelling. For authentication, no SOCKSv5 authentication methods are supported in Chrome. Writing socks5h:// is therefore not a way to change where DNS happens, and putting a username and password into a SOCKS URL does not add a negotiation Chrome performs.

socks5h is not one of the schemes that document lists, and it does not appear in the URI parser that maps a scheme to a proxy type (net/base/proxy_string_util.cc recognises socks, socks4, socks5, http, https and, when built with QUIC proxy support, quic). A spelling the parser does not recognise does not select a DNS mode; it is read as something else or rejected outright. The safe statement is that Chrome's SOCKSv5 path already resolves names proxy-side, so choosing it explicitly is what matters.

ConfigurationDNS location in ChromeAuthentication
--proxy-server=socks5://host:portProxy side, by designNo SOCKS5 auth methods in Chrome
--proxy-server=socks5h://host:portNot a scheme Chrome's URI parser recognises; socks5:// is the spelling that selects proxy-side resolutionNo SOCKS5 auth methods in Chrome
--proxy-server=http://host:portProxy resolves the CONNECT targetHTTP proxy credentials need page.authenticate() or an adapter
--proxy-server=https://host:portTLS to the proxy, then the tunnelSame credential handling; the proxy must accept TLS

When an upstream service requires SOCKS5 credentials, the usual answer is a local adapter that authenticates upstream while the browser speaks a supported protocol to the adapter. That is an architecture decision, not a Chromium flag. The adapter's listener should be restricted to loopback and to the intended destination, and its credentials should never be printed in the test log. A successful request through the adapter is evidence that the composed path worked; it is not evidence that Chrome gained native SOCKS5 authentication.

Keep DNS evidence separate from content evidence. An endpoint can echo the source address it saw without revealing which resolver looked up the destination. If the requirement is specifically "which resolver answered", test that requirement with the resolver's own controlled endpoint rather than inferring it from a page load.

An adapter adds a component that must itself be verified. A minimal adapter test has three parts: a client connection from the browser to the adapter, an authenticated session from the adapter to the upstream, and a response that names the upstream exit. If the browser-to-adapter leg succeeds but the upstream leg fails, the adapter log shows the protocol error; if both succeed but the destination rejects the request, the problem is beyond the proxy path. Recording those three results separately prevents an adapter failure from being reported as a Puppeteer launch failure.

Adapter design also affects reproducibility. A long-lived adapter can reuse an upstream session across browser runs, so two "independent" tests share a route the script never declared. Start a fresh adapter per run, or record its session identifier beside the browser version. For concurrent lanes, give each lane its own adapter listener instead of multiplexing two browsers through one session; shared state makes a later difference impossible to attribute.

A verification checklist that fails loudly

Run the checklist in order and stop at the first failed assertion.

  1. Confirm the launch call has args: ['--proxy-server=...'] and no property named proxy.
  2. Confirm there is no request interception that fulfils the verification URL.
  3. Confirm the proxy forward counter increases by exactly one for the verification request.
  4. Confirm the direct listener on the owned origin saw zero requests.
  5. Compare the endpoint-observed address against the expected proxy exit.
  6. Record the browser version, proxy scheme, direct-route exclusion list and the timestamp beside the result.

A passing run is evidence about that single request. It does not establish a stable identity, a geographic location, or that another destination will route the same way. A failing run is more useful than a screenshot, because the counter that did not move tells you which layer to inspect next.

Write the result down in a shape another engineer can compare. A useful record has six fields: the browser build, the exact args array, the proxy scheme and port, the direct-route exclusions, the endpoint's observed address and the proxy's forward count for that request. Add the UTC timestamp and the fixture revision. Two records that differ in any field are not the same experiment, even when both pages rendered successfully.

The checklist applies equally to a local proxy and to a provider endpoint, but the failure vocabulary differs. A local listener that never receives a request proves the browser did not use it; a provider that receives the request and rejects it proves the path reached the provider. Do not merge those two observations into "the proxy failed", because the fix is on opposite sides of the connection.

BotBrowser capability and limitation

BotBrowser's proxy configuration reference documents its own --proxy-server inputs, including credential handling features that stock Chromium does not provide, and the Launcher guide describes keeping one egress route per profile with an exit check before launch. That is useful when a team wants a declared route and a reproducible browser environment for an authorized test.

The limitation belongs in the same paragraph: BotBrowser does not supply a proxy service, does not authenticate an upstream SOCKS5 endpoint that requires credentials, and does not change what Puppeteer passes at launch. A Puppeteer script that omits the Chromium switch still launches a direct browser even when the underlying binary is BotBrowser's. The verification belongs to the test: count the forwards, read the owned endpoint, and record which switch produced the result.

FAQ

Does puppeteer.launch({ proxy }) work?

No. proxy is not a member of Puppeteer's LaunchOptions. The browser receives a proxy only through a Chromium argument such as --proxy-server=http://host:port. If your wrapper accepts a proxy field, verify what argument it forwards before trusting it.

Does socks5h:// make DNS resolve through the proxy?

Not as a scheme. socks5h is not listed in Chromium's proxy documentation and is not handled by the URI parser that maps a scheme to a proxy type, so it does not select a DNS mode. Chrome's SOCKSv5 path, spelled socks5://, already resolves destination names on the proxy side. Check the documentation for the version you run, and verify the resolver path with a controlled endpoint if the requirement is specific.

Can I put a username and password in a SOCKS5 URL?

Chrome's SOCKSv5 path supports no authentication methods, so credentials in that URL do not add a negotiation the browser performs. Use a local adapter that authenticates upstream, restrict it to loopback and the intended destination, and keep the credentials out of logs.

Why does the page load when the proxy is wrong?

Common causes are a fulfilled request route, a direct-route exclusion that matched, a loopback request excluded by Chromium's implicit rules, or a request that never left the page. The proxy forward counter and the owned endpoint's observed address separate those cases; the page title does not.

What should I record with a passing verification?

The exact launch arguments, browser version, proxy scheme, direct-route exclusion list, the endpoint's observed address, the proxy's forward count and a timestamp. Without those fields the result cannot be reproduced or compared with a later run.

Sources

Practical conclusion

Configure the proxy where Chromium reads it: one --proxy-server argument at launch. Then prove the path with an owned endpoint, a forward counter and a direct-listener counter, because a successful page load can come from an exclusion, an intercepted request or a direct connection. Spell the SOCKS5 endpoint socks5://, the scheme Chrome parses and the one that already resolves names proxy-side, and treat SOCKS5 credentials as an adapter problem rather than a browser flag. BotBrowser can keep the browser and profile inputs stable for the check; the configuration and the verification stay in the test.

#Puppeteer Proxy#Proxy Configuration#Socks5#Egress Verification

This article is part of the guide: Proxy Configuration Overview: A Browser Network Decision Map

Run the same check in BotBrowser

Load a profile, keep the signals you just read about consistent inside the browser, and confirm the result on your own machine before a rollout.