How to Set Up Proxies in Playwright
Route Playwright traffic through an authenticated proxy in a few lines. Copy the code below and swap in your credentials.
Quick answer
Configure the proxy with a server URL plus separate username and password, then run your Playwright script through it. Full code below.
Playwright proxy example
const { chromium } = require("playwright");
(async () => {
const browser = await chromium.launch({
proxy: {
server: "http://host:port",
username: "user",
password: "pass",
},
});
const page = await browser.newPage();
await page.goto("https://httpbin.org/ip");
console.log(await page.content());
await browser.close();
})();Playwright accepts username and password as first-class fields, so authenticated proxies work without a helper extension, unlike raw Selenium. You can set the proxy at browser launch or per browser context, which makes per-session rotation clean: give each context a fresh sticky-session endpoint. The same proxy object shape works identically in the Python API via browser_type.launch(proxy=...).
Rotating proxies
For browser automation, give each Playwright browser context its own sticky-session endpoint so every sub-request in a page load shares one IP — per-request rotation would break the session.
Best proxies to use with Playwright
Cheapest-Proxies.com EDITOR'S CHOICE
4.9Best overall value across every proxy type and use case · flexible pay-as-you-go plans
Visit Cheapest-Proxies.comBright Data
4.6Enterprise-grade proxy and web data platform · from ~$8-9/GB (residential, volume-dependent)
Read Bright Data reviewOxylabs
4.6Premium enterprise proxies and scraper APIs · from ~$8/GB (residential, volume-dependent)
Read Oxylabs reviewSmartproxy
4.5User-friendly proxies with excellent price-to-performance · from ~$3.50-7/GB (residential)
Read Smartproxy reviewOur #1 pick is a sponsored partner. Remaining providers are ranked editorially by rating and value.
Frequently Asked Questions
What proxies work best with Playwright?
Residential or rotating proxies from a reliable provider give the best success rate for Node.js / Python projects.
Does Playwright support authenticated proxies?
Yes. Provide the username and password (as a URL or separate fields) and Playwright handles the auth handshake.
How do I add a proxy in Playwright?
Pass a server URL plus username and password to Playwright’s proxy option, as shown in the code above.
Can Playwright rotate proxies automatically?
Use one sticky session per browser context; rotate by launching a new context with a fresh endpoint rather than per request.
Related Guides
Best proxies for Playwright
Across the providers we compare, this network stood out for value and consistent performance.
Visit Cheapest-Proxies.com