.bp-clean-small-figure{max-width:540px!important;width:100%!important;margin:22px auto!important;padding:10px!important;border-radius:20px!important;background:#fff!important;box-shadow:0 10px 28px rgba(7,18,5,.10)!important}.bp-clean-small-figure img,.bp-clean-small-image{display:block!important;width:100%!important;height:auto!important;border-radius:16px!important}.bp-clean-small-figure figcaption{font-size:14px!important;line-height:1.45!important;color:#4b5563!important;margin-top:10px!important;text-align:center!important}

Chrome and Firefox automation guide

How to Use Proxies with Puppeteer

Configure browser-wide and per-context proxies in Puppeteer with authentication, secure secrets, exit verification, concurrency controls and practical debugging.

Puppeteer proxy configuration workflow
A robust Puppeteer proxy worker loads configuration safely, authenticates before navigation and verifies the actual exit.

Short answer: how to use a proxy with Puppeteer

Launch Puppeteer with Chrome’s --proxy-server argument for a browser-wide proxy, or create a browser context with proxyServer in current Puppeteer versions. For a proxy that uses basic authentication, call page.authenticate() before the first navigation. Verify the public exit, keep the endpoint stable for the context, and close resources in a finally block.

Puppeteer is a JavaScript browser automation library for Chrome and Firefox, described in the official Puppeteer overview. Proxy behavior depends on the controlled browser and protocol, so test the exact combination you deploy rather than assuming a command-line flag covers every authentication method.

Responsible automation: use Puppeteer on websites and accounts you own or are authorized to test. Keep concurrency bounded and do not rotate proxies to evade access controls or rate limits.

Set a browser-wide proxy at launch

The launch argument supplies the proxy server to Chrome. Keep the value separate from credentials and validate it before passing it into the browser.

import puppeteer from 'puppeteer';

const proxyServer = process.env.PROXY_SERVER;
if (!proxyServer) throw new Error('PROXY_SERVER is required');

const browser = await puppeteer.launch({
  headless: true,
  args: [
    `--proxy-server=${proxyServer}`,
    '--proxy-bypass-list=localhost;127.0.0.1'
  ]
});

try {
  const page = await browser.newPage();

  if (process.env.PROXY_USERNAME) {
    await page.authenticate({
      username: process.env.PROXY_USERNAME,
      password: process.env.PROXY_PASSWORD || ''
    });
  }

  await page.goto('https://api.ipify.org?format=json', {
    waitUntil: 'domcontentloaded',
    timeout: 30_000
  });

  console.log(await page.evaluate(() => document.body.innerText));
} finally {
  await browser.close();
}

The official Page.authenticate documentation notes that request interception is enabled behind the scenes and can affect performance. Authenticate before navigation and measure the result rather than hiding timing changes with a very large timeout.

Do not embed username:password in the launch argument. It can appear in process lists, CI diagnostics or crash reports. Use environment variables or a secret manager and mask any error message that includes configuration.

Configure a proxy for an isolated browser context

Recent Puppeteer APIs include proxyServer and proxyBypassList in browser context options. This is useful when separate contexts need different exits while sharing one browser process. Check the Puppeteer version in your project because older versions may require a launch-level proxy or a different design.

const context = await browser.createBrowserContext({
  proxyServer: process.env.PROXY_SERVER,
  proxyBypassList: ['localhost', '127.0.0.1']
});

const page = await context.newPage();

if (process.env.PROXY_USERNAME) {
  await page.authenticate({
    username: process.env.PROXY_USERNAME,
    password: process.env.PROXY_PASSWORD || ''
  });
}

await page.goto('https://example.com');
await context.close();

The official BrowserContextOptions reference documents the proxy server option and points to Page.authenticate for username/password. Keep one stateful journey inside one context and do not swap the route while cookies or account state are active.

Puppeteer per-context proxy isolation
Current Puppeteer context options can align one proxy with one isolated cookie and storage environment.

Verify the proxy before the real page

An IP endpoint gives a cheap routing check, but production acceptance should verify four things: the observed IP matches the assigned endpoint or expected pool, location fits the scenario, the real target loads, and required content is present. Store those results with a masked proxy identifier.

const response = await page.goto(
  'https://api.ipify.org?format=json',
  { waitUntil: 'domcontentloaded', timeout: 30_000 }
);

if (!response || !response.ok()) {
  throw new Error(`IP check failed: ${response?.status()}`);
}

const { ip } = JSON.parse(
  await page.evaluate(() => document.body.innerText)
);

if (!ip) throw new Error('No proxy exit IP returned');

Use the proxy tester before browser automation when the endpoint itself is uncertain. This separates a dead proxy from a Puppeteer configuration or page assertion problem.

Proxy assignment for pages, contexts and workers

All pages in a launch-level browser normally share the same proxy. If each worker needs a different endpoint, use supported per-context proxy options or launch separate browsers. Choose based on isolation requirements and resource cost, then document the boundary.

Model Advantage Trade-off
One browser, one proxy Simple configuration and cleanup All contexts share the network exit
One browser, per-context proxy Lower browser overhead with isolated sessions Requires a current supported Puppeteer version
One browser per proxy Strong process and network isolation Higher memory and startup cost
Rotating gateway New independent jobs can receive different exits Session behavior must be understood and recorded

For account or checkout testing, keep one stable endpoint for the context. For independent public screenshots, allocate a new proxy at job start if the workflow permits it. The proxy pool guide covers health checks, quarantine and replacement without making every browser worker invent its own policy.

Performance and bandwidth controls

Browser automation loads scripts, styles, images, fonts and third-party resources. That consumes more bandwidth than an API request. Measure complete page time and response errors through the actual target. Do not assume that the fastest IP-check result will be fastest for a complex application.

Puppeteer’s request interception can block unnecessary assets in an approved performance test, but it changes page behavior and can disable useful evidence. Use a named test mode and compare it with a full-page control. Never block resources merely to hide a broken layout or missing content.

  • Set navigation and operation timeouts separately.
  • Bound concurrent browsers and contexts.
  • Record bytes or request count when bandwidth matters.
  • Close idle pages and contexts promptly.
  • Retain screenshots and traces only as long as required.
  • Respect target rate limits and permitted test schedules.

The bandwidth and concurrency guide helps translate page weight and simultaneous sessions into a realistic proxy plan.

Troubleshoot Puppeteer proxy errors

Error pattern Check first Avoid
ERR_PROXY_CONNECTION_FAILED Proxy protocol, host, port and reachability Retrying the same invalid endpoint in a loop
407 authentication Call page.authenticate before navigation and verify credentials Putting secrets in command-line arguments
ERR_TUNNEL_CONNECTION_FAILED HTTPS CONNECT support, firewall and upstream response Disabling TLS verification without diagnosis
Navigation timeout Target response, proxy latency and page wait condition Increasing all timeouts indefinitely
Wrong IP Bypass list, context option and observed exit Trusting only the provider label
Random parallel failure Concurrency, shared state and proxy capacity Adding unbounded automatic retries

Listen to request failures, response status and console errors, but redact authorization data. The proxy error guide helps distinguish transport, authentication, destination and gateway failures.

Puppeteer proxy error layers
Collect launch, authentication, tunnel and target evidence before choosing a retry.

A maintainable Puppeteer proxy worker

  1. Acquire a healthy proxy from a central pool and reserve it for the job.
  2. Launch the browser or context with the endpoint and a narrow bypass list.
  3. Apply credentials before the first request.
  4. Verify the exit IP and expected location.
  5. Run the authorized test with bounded timeouts and clear assertions.
  6. Capture evidence with credentials and private data removed.
  7. Close page, context and browser in a finally block.
  8. Return, quarantine or replace the endpoint based on classified results.

For a broader JavaScript HTTP client setup, use the Node.js proxy guide. For cross-browser testing and integrated traces, compare the Playwright proxy guide. Do not duplicate proxy allocation logic in every automation script.

Authenticated proxies, sessions and safe retries

Authentication deserves its own design decision in Puppeteer. The browser launch argument selects the proxy route, while page authentication supplies credentials when the proxy challenges the request. Apply credentials before the first navigation so an initial request cannot escape the intended flow or fail with a 407 response. If the target website also uses HTTP authentication, test the interaction carefully because the browser may receive challenges from two different layers.

Keep proxy credentials out of source control and screenshots. Read them from environment variables or a secret manager, validate that every required field exists, and redact usernames as well as passwords from exception messages. A practical log entry needs only a non-secret proxy ID, the selected region, the observed exit IP, timing and a normalized error category.

Preserve identity for one browser journey

Assign one proxy session to a complete workflow: opening the site, accepting consent, signing in and completing the action. Rotating between steps can invalidate cookies or trigger security controls. Rotation is safer between independent jobs. If your provider supports sticky sessions, create the session identifier at job allocation time and release it when the browser context closes.

Retry the failing layer, not the whole queue

Separate connection failures, proxy-authentication failures, navigation timeouts and page-logic errors. A connection timeout can justify a different healthy endpoint. A 407 normally calls for corrected credentials. A selector error usually belongs to the automation code or the target page, not to the proxy. Limit retries, add exponential backoff and preserve the last diagnostic screenshot or HTML sample when permitted.

Before scaling concurrency, measure success with a small controlled batch. Confirm that each worker receives the intended exit, that the target tolerates the request rate and that failed contexts close cleanly. Use the proxy formatter to normalize imported lists and the proxy tester to remove obviously unhealthy entries before Puppeteer starts.

Puppeteer proxy FAQ

How do I set a proxy in Puppeteer?

Use the Chrome launch argument –proxy-server for a browser-wide route or a supported proxyServer option when creating an isolated browser context.

How do I authenticate an HTTP proxy?

Call page.authenticate with username and password before the first navigation, then verify the result against the actual proxy and browser version.

Can each Puppeteer context use a different proxy?

Current BrowserContextOptions support proxyServer. Confirm the installed Puppeteer version and test the exact browser combination before relying on it.

Why is page.authenticate slower?

Puppeteer notes that request interception is enabled behind the scenes to implement authentication, which can affect performance.

Should I include credentials in –proxy-server?

No. Command-line arguments can be exposed in process lists and logs. Load credentials separately from a secret store or environment.

How can I confirm Puppeteer uses the proxy?

Open a controlled IP endpoint, compare the exit with the assigned proxy, then load the authorized target and record both outcomes.

Use tested proxies in reproducible developer workflows

Use stable private proxies for stateful browser contexts, control concurrency from a central pool, and preserve classified evidence when a page or tunnel fails.

Proxies for Puppeteer: practical buying notes

This page is strongest when it connects setup details to a buying decision. Use stable private proxies when you need repeatable tests, account-safe sessions, reproducible reports or clean troubleshooting. Use cheaper semi-dedicated proxies for early testing and move important workflows to dedicated IPs once the process is proven.

Need Recommended proxy behavior Related guide
Stable sessions Use static or sticky private proxies. Static vs rotating proxies
Troubleshooting Test format, authentication and exit IP before scaling. Proxy tester
Location-sensitive checks Choose proxy country close to the target audience. Choose proxy location

What proxy type should I start with?

Start with static private proxies when accuracy and troubleshooting matter. Use rotation only when the workflow can tolerate IP changes.

Should I test proxies before using them?

Yes. Test one proxy outside the application first, then import the same working format into the real tool.

Related BuyProxies guides

These related pages help connect the setup, troubleshooting and buying decisions instead of treating each proxy problem in isolation.

Proxy authentication failed

Use this guide as the next step when you need a more specific proxy workflow.

HTTP 407 proxy authentication required

Use this guide as the next step when you need a more specific proxy workflow.

Proxy timeout errors

Use this guide as the next step when you need a more specific proxy workflow.

Best proxies for scraping

Use this guide as the next step when you need a more specific proxy workflow.

How many proxies for scraping

Use this guide as the next step when you need a more specific proxy workflow.

How many proxies for multiple accounts

Use this guide as the next step when you need a more specific proxy workflow.

Scroll to Top