Guides · Browser Automation

Using proxies with Puppeteer, Playwright, and Selenium

Automated browsers require proxies to isolate IPs across sessions or browse pages as users in another country. The common challenge is that Chrome ignores usernames and passwords in the --proxy-server argument, so each library provides its own method to handle proxy authentication.

Author: Bùi Toàn · Updated: 19/11/2026

Playwright (Node.js, Python)

  • When launching a browser: chromium.launch({ proxy: { server: "http://IP:PORT", username: "user", password: "pass" } }).
  • One proxy per context: browser.newContext({ proxy: { server, username, password } }). A single browser instance can run multiple contexts, each with its own IP, consuming far less overhead than launching multiple browsers.
  • Python uses the same structure with a dictionary: p.chromium.launch(proxy={"server": "http://IP:PORT", "username": "user", "password": "pass"}).
  • Firefox and WebKit in Playwright accept the exact same proxy configuration.

Puppeteer

  1. Launch the browser with the command-line flag: puppeteer.launch({ args: ["--proxy-server=http://IP:PORT"] }).
  2. For each page, call await page.authenticate({ username: "user", password: "pass" }) prior to page.goto.
  3. If you require multiple proxies within a single browser, use browser.createBrowserContext({ proxyServer: "http://IP:PORT" }) in modern Puppeteer versions, alongside page.authenticate on each page.
  4. Verify connectivity by navigating to https://api.ipify.org and reading the response body.

Can Selenium use proxies with a username and password?

Yes, but not directly. ChromeDriver has no parameter for proxy username and password, and Chrome's proxy authentication dialog cannot be controlled with standard Selenium. Common workarounds include: using the selenium-wire library (Python) which accepts proxies in http://user:pass@IP:PORT format; creating a small Chrome extension to handle authentication events and loading it at startup; or using Firefox with a profile where proxy credentials are saved. For new projects, Playwright makes this much simpler.

What should you keep in mind when running Playwright and Puppeteer through proxies long term?

Set timeouts and retry on network errors, close pages and contexts when finished, and limit concurrent sessions per IP to avoid 429 errors.

  • Set sensible navigation timeouts (30–60 seconds) and implement retry logic for transient network failures.
  • Close pages and contexts promptly upon completion to avoid leaking idle connections.
  • Limit concurrent sessions running through a single IP; target services may return 429 if request volume from one address is too high.
  • Align the context's time zone and locale with the proxy country (timezoneId, locale in Playwright).

Need a proxy? Buy dedicated proxies with automatic activation

Dedicated IPv4 proxies in 9 countries from 20.000₫/IP/month when purchasing from 2.000 IPs (39.000₫ for 1 IP) and static ISP proxies in Vietnam, US. HTTP(S) and SOCKS5 with username and password, unlimited bandwidth, automatically provisioned after payment. Note that Vietnam proxies currently use the HTTP(S) protocol and do not support SOCKS5 yet.

Buy proxies now

Frequently Asked Questions

Why does --proxy-server=http://user:pass@IP:PORT fail to work?+

Chrome ignores the username and password in this argument. Use page.authenticate (Puppeteer) or Playwright's built-in proxy parameters instead.

Can ONET proxies be used with headless browsers?+

Yes. Proxies operate identically whether running in headless or GUI mode.