$0.00
A

Proxyvizr blog

How to set up a proxy in Puppeteer

Puppeteer drives Chrome, so the proxy is set when the browser launches, while the username and password are passed separately on the page. Here is a working setup and the Chrome limitations.

Where to get the proxy details

Buy proxies in the Proxyvizr catalog or unified search and open "My proxies". Each proxy has a host:port:username:password line there, and traffic packages generate a list for the country you need on the same page. If your software needs another format, convert the list with the free Proxyvizr proxy converter.

Proxy with username and password

The proxy address goes in a launch flag, and the username and password go through page.authenticate:

const puppeteer = require('puppeteer');
(async () => {
  const browser = await puppeteer.launch({
    args: ['--proxy-server=http://HOST:PORT'],
  });
  const page = await browser.newPage();
  await page.authenticate({ username: 'LOGIN', password: 'PASSWORD' });
  await page.goto('https://proxyvizr.com/api/my-ip');
  console.log(await page.evaluate(() => document.body.innerText));
  await browser.close();
})();

SOCKS5

Chrome supports SOCKS5 only without a username and password: --proxy-server=socks5://HOST:PORT works for proxies with IP authentication. For SOCKS5 with a login, use HTTP access from the same provider if available, or Playwright with an HTTP proxy.

Several proxies

The proxy applies to the whole browser. To work with different IPs in parallel, launch a separate browser instance per proxy. For rotation, a traffic package gateway address is more convenient.

Common mistakes

Putting the username and password into --proxy-server: Chrome ignores them, use page.authenticate. Calling authenticate after goto: set it before navigating. SOCKS5 with a password: Chrome does not support it.

Conclusion

In Puppeteer the proxy address is passed at launch and the credentials through page.authenticate. Chrome does not support SOCKS5 with a password.

Ready to pick your proxies?

Create an account in a minute and choose proxies for your task — residential, mobile, ISP, datacenter and SOCKS5 from trusted providers.