Integrations · Intermediate

Using proxies with Puppeteer and headless Chrome

Set a proxy at browser launch or in a supported Puppeteer browser context, then supply credentials before navigation. Check the assigned exit inside each context and keep independent workflows in separate sessions.

2 min read 5 sections Reviewed Editorial team Proxy Cyber

Launch with a proxy and authenticate#

Node.js
import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
  headless: true,
  args: ["--proxy-server=http://res.proxy-cyber.com:9000", "--no-first-run"],
});
const page = await browser.newPage();
await page.authenticate({ username: "USER-cc-us-sid-run1-ttl-30m", password: "PASS" });

await page.goto("https://api.ipify.org", { waitUntil: "domcontentloaded", timeout: 45000 });
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();

Use a distinct session identifier for each independent workflow, where the assigned gateway supports it. Confirm the permitted duration and location parameters in your connection details. A residential device can disconnect before the requested duration; a sticky session is not a guarantee of the same IP for days. For a fixed address, compare a dedicated static product.

One proxy per browser#

The launch-level --proxy-server setting applies to that browser’s default routing. Current Puppeteer also supports proxyServer in browser.createBrowserContext(), with credentials supplied through page.authenticate(). Use separate contexts for different proxy settings and separate user-data directories for persistent profiles; verify the exit inside each context.

Block images, fonts and media#

Request interception
await page.setRequestInterception(true);
page.on("request", (req) => {
  const t = req.resourceType();
  if (["image", "media", "font", "stylesheet"].includes(t)) return req.abort();
  req.continue();
});

Consistency#

  • Set Accept-Language and the time zone to the exit's country: page.setExtraHTTPHeaders({\"Accept-Language\": \"de-DE,de;q=0.9\"}) and page.emulateTimezone(\"Europe/Berlin\").
  • Disable WebRTC leaks with --force-webrtc-ip-handling-policy=disable_non_proxied_udp in the launch args.
  • Keep one browser per account; reuse its user data directory if the account should look like a returning device.

Errors you will meet#

SymptomCauseFix
net::ERR_TUNNEL_CONNECTION_FAILEDGateway refused the CONNECT: credentials, parameter or no exitReproduce with cURL -v to read the gateway code
net::ERR_PROXY_AUTH_UNSUPPORTED / promptsauthenticate() called after navigationCall page.authenticate before goto
Same IP in every browserSame session id reusedUse a distinct -sid- per browser or omit it
Very slow first loadHousehold exit plus heavy pageBlock resources; raise timeout to 45 s

Questions people ask#

Can Puppeteer use SOCKS5 with a password?

Chrome does not support SOCKS5 authentication. Use the HTTP proxy on port 9000 with page.authenticate, or whitelist your server IP and pass --proxy-server=socks5://res.proxy-cyber.com:9001.

Your account

Manage your proxies in one account

Compare networks, place orders and follow your balance and support requests from one dashboard. Our team reviews payments and provides connection details after delivery.

Create account