QA & Automation · November 26, 2026 · 6 min read · Ler em português
Proxy in Playwright and Puppeteer: setup and authentication
How to set up a proxy with username and password in Playwright and Puppeteer, one proxy per context, SOCKS5 authentication limits and how to rotate the IP between runs.
Playwright and Puppeteer are the two most used browser automation tools in JavaScript (Playwright also has a Python version). Both handle authenticated proxies better than Selenium, each in its own way.
Playwright
In Playwright, the proxy is passed when launching the browser as an object with server, username and password: server in the format http://host:port, and the credentials in separate fields. The browser opens already authenticated, with no password window.
Playwright also supports a proxy per context. One browser can open several contexts, each with its own proxy, cookies and storage. It's the lightest way to simulate different users: one context per identity, one Mobile Proxy per context.
SOCKS5 with a password
Playwright's Chromium doesn't support SOCKS5 proxies with username and password. With the Mobile Proxy, use HTTP mode (the same proxy works with both protocols; switch it in the panel) or IP authorization, which removes the need for credentials.
Puppeteer
In Puppeteer, the proxy goes in as a Chrome argument (--proxy-server=http://host:port), and authentication is done on the page with page.authenticate, passing username and password before the first navigation. Forgot authenticate? The first request comes back with error 407.
Check before running
- Open a "what is my IP" page as the first step and log the result.
- Set the context's timezone and locale consistent with the IP: America/Sao_Paulo and pt-BR. Both tools allow this when creating the context or page.
- Use a generous navigation timeout in early tests; mobile networks have higher latency than datacenters.
Rotating the IP
Between runs, call the Monthly plan's rotation link, wait a few seconds and open a new context. The limit is one rotation per minute per proxy. For flows with login, do the opposite: lengthen the automatic rotation interval or turn it off during the run.
Ready to run on a dedicated Mobile Proxy?