DashboardDashboardLog inTry Free for 2 Hours

How to set up a Puppeteer proxy with authentication

Puppeteer splits proxy setup into two parts. Chrome receives the proxy address as a launch argument, and each page supplies the login with page.authenticate. This guide covers both, a per-context option for running several proxies in one browser, and how a long script should treat the IP rotation timer.

HOST, PORT, USERNAME and PASSWORD in the examples are placeholders for the values in your dashboard. Plans are on pricing.

AtlasProxies Team · Updated · 4 min read

  • 1Address at Launch, Login per Page--proxy-server routes the traffic, and page.authenticate answers the proxy's login request.
  • 2Credentials Stay Out of the SwitchChrome ignores a username and password written into --proxy-server.
  • 3HTTP for LoginsChrome has no SOCKS5 authentication, so use the proxy as HTTP in Puppeteer.
On This Page
  1. Route Chrome through the proxy
  2. Log in with page.authenticate
  3. One proxy per browser context
  4. Why SOCKS5 with a login does not work here
  5. Confirm the exit IP
  6. Rotation timer and long scripts
  7. Bandwidth for headless crawls

Route Chrome through the proxy

Pass the address in the args array when you launch:

const browser = await puppeteer.launch({ args: ['--proxy-server=http://HOST:PORT'] });

args is Puppeteer's list of extra command-line arguments for the browser, and --proxy-server is Chromium's own switch for a fixed proxy. With it set, every page in the default context goes through the proxy.

Leave the login out of that string. The switch takes a scheme, host and port, and Chromium drops any username and password written into it, a behavior recorded in Chromium's issue tracker. The next step supplies the login instead.

Log in with page.authenticate

page.authenticate takes an object with username and password and uses it to answer HTTP authentication challenges, including the one an HTTP proxy sends. Call it on each new page before the first navigation:

const page = await browser.newPage();
await page.authenticate({ username: 'USERNAME', password: 'PASSWORD' });
await page.goto('https://api.ipify.org');

The credentials belong to the page, not the browser. A page opened later needs its own call, so a small helper that creates a page and authenticates it in one step keeps you from missing one. Passing null turns authentication off again for that page.

One proxy per browser context

Browser context options include proxyServer, so one browser can hold several contexts that use different proxies. Each context has its own cookies and cache and shares neither with the others:

const context = await browser.createBrowserContext({ proxyServer: 'http://HOST:PORT' });

Pages from "await context.newPage()" use that proxy, and each still needs page.authenticate with the matching login, as Puppeteer's docs for proxyServer point out.

This suits a script that manages several accounts from one machine: one context per account, one proxy per context, and a map from each context to its credentials. proxyBypassList on the same options names hosts that should skip the proxy.

Why SOCKS5 with a login does not work here

Chromium's proxy documentation states that Chrome supports no authentication methods for SOCKSv5. Puppeteer drives Chrome, so a SOCKS5 proxy that needs a username and password cannot be used from it directly. Set the proxy to HTTP in My Proxies, copy the proxy line again, and use the http:// form above.

An HTTP proxy still carries HTTPS sites. Chrome opens a tunnel through the proxy, and the encrypted session runs between the browser and the site. HTTP vs SOCKS5 compares the two protocols in more detail.

Confirm the exit IP

After page.goto('https://api.ipify.org'), read the body with "await page.evaluate(() => document.body.innerText)" and log it. It should match Current Public IP in the proxy's IP Rotation panel and differ from your own address. A page that never authenticated fails at the proxy with an authentication error, the case covered in 407 Proxy Authentication Required.

Rotation timer and long scripts

The proxy takes a new IP each time its timer fires, at the interval you chose between every 5 and every 120 minutes. The launch argument and the login stay valid, so a running browser keeps working through the change. A navigation that overlaps the switch can fail with net::ERR_CONNECTION_RESET or a similar network error, which page.goto throws.

No API or link moves the IP early. Plan the script around the timer with a few habits.

  • Catch navigation errors and retry the goto after a short pause, up to a fixed number of attempts.
  • Keep each step safe to repeat. Before resubmitting a form, check the page for the result of the first attempt.
  • Store progress outside the browser, such as the last finished item in a file, so a restarted script continues where it stopped.
  • Note the exit IP when a job starts and ends, which shows whether a rotation fell inside it.

Good to Know. An interval longer than a typical job keeps most jobs on a single IP. Rotating mobile proxies covers how the timer works.

Bandwidth for headless crawls

Eco and Pro come with unlimited bandwidth and 15 GB/day of fair use per proxy. When a proxy reaches 15 GB in a day, it stops until the limit resets the next day. Headless Chrome downloads every image, font and video a page asks for, so a script that needs only text can call page.setRequestInterception(true) and abort requests whose resourceType() is image, media or font. Ultra is truly unlimited for jobs that need full pages.

For scheduled runs, automation proxies covers rental lengths and plan choice. Run automation that respects each website's terms and our Acceptable Use Policy.

Frequently Asked Questions

How do I add a proxy with a login to Puppeteer?

Launch with args: ['--proxy-server=http://HOST:PORT'], then call page.authenticate with the username and password on each page before page.goto.

Why is the username and password in --proxy-server ignored?

Chromium does not read credentials from that switch. Supply them with page.authenticate instead.

Can Puppeteer use a different proxy for each context?

Yes. Pass proxyServer to browser.createBrowserContext, and authenticate each page opened in that context.

Does Puppeteer work with SOCKS5 proxies that need a login?

No, because Chrome has no SOCKS5 authentication. Use the proxy as HTTP, which you can switch to in My Proxies.

Do I need to relaunch the browser after the IP rotates?

No. The address and login stay the same. Retry any navigation that failed at the moment of the change.

Your first mobile proxy is two minutes away.

Sign up, pick a country, and your login arrives in seconds.