GBProxies

How to Use Authenticated Proxies with Puppeteer

Chrome takes the proxy host and port as a launch flag, and Puppeteer answers the login prompt with page.authenticate.

Steps

  1. Launch Chrome with --proxy-server=host:port
  2. Call page.authenticate with your proxy username and password
  3. Turn on request interception to block images and fonts
  4. Open one browser per session id for sticky IPs

Example code

import puppeteer from "puppeteer";

const browser = await puppeteer.launch({ args: ["--proxy-server=gw.gbproxies.cc:10000"] });
const page = await browser.newPage();
await page.authenticate({ username: "USERNAME-cc-fr-sid-shop1-ttl-30", password: "PASSWORD" });
await page.setRequestInterception(true);
page.on("request", (r) => (["image", "font", "media"].includes(r.resourceType()) ? r.abort() : r.continue()));
await page.goto("https://api.ipify.org");
console.log(await page.content());
await browser.close();

Replace USERNAME and PASSWORD with the proxy login from the Proxies page of the console. Port 10000 is residential HTTP; see the ports of every product below.

Tips

  • Blocking images often cuts traffic per page by more than half
  • A sticky session id keeps the same IP for a whole browsing flow

Common questions

Why does Chrome still show a login popup?

page.authenticate must run before the first navigation of that page.

How to Use Authenticated Proxies with Puppeteer