Playwright supports HTTP(S) and SOCKSv5 proxies, and you configure them either globally at browser launch or per browser context. Use global setup when every page shares one proxy; use per-context when you need multiple simultaneous proxies, such as parallel test sessions or region-specific scraping runs. Authentication takes a username/password pair on the same proxy object, and a bypass field lets you exclude specific hosts from routing through the proxy at all.
TL;DR:
- Playwright proxies can be set globally at browser launch for shared proxies or per context for multiple IPs during parallel sessions, with both options using the same configuration structure.
- Proxy authentication relies on the proxy server issuing a 407 challenge, meaning credentials are sent after this challenge, which can cause issues if the proxy expects preemptive credentials.
- Using the bypass field with wildcards, IP ranges, or local hostnames allows internal or local traffic to bypass the proxy, reducing unnecessary routing.
- Proxy rotation strategies should match the task: keep the same IP for login sessions, or rotate IPs at request level for high-volume scraping, and pair proxies with geo-targeting to avoid detection.
- Securing proxy credentials in CI involves using environment variables, rotating credentials regularly, and avoiding shared accounts to prevent leaks and ensure reliability.
Table of Contents
- How Do You Set Up a Proxy in Playwright?
- How Does Playwright Handle Proxy Authentication and Bypass?
- What Proxy Rotation Strategy Should You Use?
- Why Is Your Playwright Proxy Failing?
- How Do You Keep Proxy Credentials Secure in CI?
- Matching the Playwright Task to the Right Proxy Type
- An Honest Take on Playwright Proxy Setup
- Get Your Playwright Proxy Endpoint Running Today
- Sources
- FAQ
How Do You Set Up a Proxy in Playwright?
Both configuration paths use the same shape of object. You supply a server string, optional username/password fields for authenticated proxies, and an optional bypass list. The difference is scope, not syntax.
Global, at browser launch (Node/JavaScript):
const browser = await chromium.launch({
proxy: {
server: 'http://proxy.example.com:8000',
username: 'user',
password: 'pass'
}
});
Per-context (JavaScript), for isolated sessions:
const context = await browser.newContext({
proxy: { server: 'socks5://proxy.example.com:1080' }
});
Per-context configuration matters more than it looks. If you're running five parallel test users, each behind a different exit IP, you don't relaunch the browser five times. You open five contexts inside one browser instance, each with its own proxy. That's lighter on memory and faster to spin up.

If you're setting global config through Playwright Test's playwright.config.ts, the same proxy object goes inside use:
use: {
proxy: { server: 'http://proxy.example.com:8000', username: 'user', password: 'pass' }
}
- Python:
browser = p.chromium.launch(proxy={"server": "...", "username": "...", "password": "..."}) - Java:
LaunchOptions().setProxy(new Proxy("http://proxy.example.com:8000").setUsername("user").setPassword("pass"))
The Playwright network docs cover language-specific parameter names in full, since minor casing differences (server vs httpProxy) trip up developers moving between JavaScript and Java.
How Does Playwright Handle Proxy Authentication and Bypass?
The proxy object has four fields that matter: server, username, password, and bypass. Playwright doesn't send credentials preemptively on every request. It typically relies on the browser to build a Proxy-Authorization header only after the proxy server issues a 407 Proxy Authentication Required challenge, a behavior documented in a Playwright GitHub issue that trips up a lot of first-time setups. If your proxy expects credentials on the very first packet instead of via the standard 407 handshake, the connection can fail even when the username and password are correct.
SOCKSv5 changes the picture slightly, since SOCKS5 authentication happens at the connection level, not through HTTP headers, so the 407 challenge flow is irrelevant there.
The bypass field takes a comma-separated list, letting you route internal or local traffic around the proxy entirely:
proxy: {
server: 'http://proxy.example.com:8000',
bypass: 'localhost,127.0.0.1,*.internal.example,192.168.*'
}
- Wildcards work for subdomains (
*.internal.example) - CIDR-style patterns work for IP ranges (
192.168.*) - Test the same proxy string in a normal Chrome window first, per community troubleshooting threads, to confirm the credentials work before blaming Playwright
What Proxy Rotation Strategy Should You Use?
Rotation strategy depends entirely on whether your workflow needs continuity or volume. Logging into an account and staying logged in needs a sticky session on one IP. Scraping ten thousand product pages needs the opposite: a fresh IP every few requests to avoid rate limits.
A simple round-robin selector looks like this in JavaScript:
const proxies = [proxy1, proxy2, proxy3];
let i = 0;
function nextProxy() {
return proxies[i++ % proxies.length];
}
For less predictable patterns, swap the modulo index for Math.floor(Math.random() * proxies.length). Both approaches assign a proxy at context creation, so each simulated user keeps one IP for its whole session, which is what most login-dependent test flows need anyway.
- Per-context rotation for parallel sessions that must stay isolated from each other.
- Per-request rotation for high-volume scraping where each request can hit a different endpoint.
- Geo-paired rotation, pairing proxy location with
localeandgeolocationcontext options so a Spain-based IP isn't paired with an English-US locale, a mismatch BrowserStack's proxy guide flags as a common tell that gets automated sessions flagged.
Pro Tip: Sticky sessions preserve cookies and login state across a run, but they also concentrate all your traffic on one IP. If that IP gets flagged mid test, the whole session dies with it. Rotate on failure, not just on a timer.
Why Is Your Playwright Proxy Failing?
Most proxy failures fall into three buckets: the proxy itself is unreachable, the credentials never get sent, or the endpoint is slow enough to trip your timeout. Work through them in that order.
- Confirm the proxy is actually reachable with
curl -x http://user:pass@proxy.example.com:8000 https://example.combefore touching your Playwright script at all. - Double-check the port and protocol prefix (
http://vssocks5://); a mismatched scheme throwsnet::ERR_PROXY_CONNECTION_FAILEDeven when the server is fine. - Check the proxy's own logs for a missing
Proxy-Authorizationheader. Since Playwright often only sends it after the server issues a 407 challenge, a documented GitHub issue shows this exact pattern causing silent auth failures. - Load the same proxy in a regular browser window first. If it works there and fails in Playwright, the problem is your config, not the proxy provider.
- For corporate networks running SSL inspection, set
ignoreHTTPSErrors: trueand expect self-signed certificate warnings as the norm, not the exception.
Flaky proxy endpoints also benefit from longer navigation timeouts and a retry wrapper around page.goto(). A proxy that answers in 400ms on a good day can spike past your default 30 second timeout under load, and that's a proxy problem, not a script bug.
How Do You Keep Proxy Credentials Secure in CI?
Never hardcode proxy credentials in a config file that gets committed. Pull them from environment variables or a secret manager and inject them at runtime:
proxy: {
server: process.env.PROXY_SERVER,
username: process.env.PROXY_USER,
password: process.env.PROXY_PASS
}
- Rotate proxy credentials on a schedule, not just after a suspected leak.
- Scope each credential set narrowly. A scraping job and a login-test job shouldn't share one proxy account.
- Gate any use of
ignoreHTTPSErrorsbehind a documented reason. It's a legitimate fix for corporate SSL inspection, but it's also a way to silently mask a real certificate problem. - Build your CI pipeline to fail immediately if a required proxy environment variable is missing, rather than running the suite against no proxy at all and producing confusing results.
Pro Tip: If your pipeline supports multiple environments, make the proxy config injectable per stage. A staging pipeline hitting the production proxy pool by accident is a classic way to burn through a monthly bandwidth allocation overnight.
Matching the Playwright Task to the Right Proxy Type
The setup code is identical no matter which proxy class you plug in. The results aren't. Account management and login-heavy flows tend to do best on dedicated static ISP proxies, since a consistent IP looks less suspicious to a platform tracking session behavior over time. High-volume scraping across many target sites usually calls for rotating residential proxies with country, state, or city targeting, which lowers block risk at scale. Mobile-only flows, like verifying an app or ad experience that only renders on cellular networks, need mobile 4G/5G proxies specifically. Natproxies offers all three, plus unlimited bandwidth on its ISP proxy plans.
An Honest Take on Playwright Proxy Setup
Most guides treat proxy configuration as a solved problem: paste the object, add credentials, done. It isn't, and the gap shows up exactly where this article spent the most words: authentication timing and rotation strategy, not syntax.

The syntax is genuinely simple. Anyone can copy a proxy: { server, username, password } block in thirty seconds. What actually breaks production runs is the assumption that Playwright behaves like a script instead of a browser engine that waits for a 407 challenge before sending credentials. Teams debug that mismatch for hours because they're staring at their code instead of their proxy's log.
The other overrated piece of advice is "just rotate proxies." Rotation without a strategy tied to session type creates more problems than it solves. A login flow rotated per-request will fail constantly, not because the proxy is bad, but because the target site sees a session jumping IPs mid-login and shuts it down. Match the rotation pattern to the job first. Pick the protocol and scope second. That order gets skipped constantly, and it's the actual reason proxy setups fail in production more often than in a quick local test.
— proxy
Get Your Playwright Proxy Endpoint Running Today
Swapping a placeholder for a real endpoint takes one line. Replace process.env.PROXY_SERVER with a Natproxies connection string, and your existing launch or context config keeps working without touching the rest of your script.

For login-dependent test flows and account management, dedicated static ISP proxies give you a fixed IP with unlimited bandwidth, no per-GB math to track mid-run. For scraping across many domains or regions, rotating residential proxies with country, state, and city targeting cut block risk without you writing your own rotation logic. Check current pricing and provision an endpoint directly from Natproxies to get a working proxy string into your Playwright config in the next few minutes.
Sources
- Network | Playwright
- Playwright HTTP proxy Authentication issue · Issue #32567 · microsoft/playwright
- Setting Up Proxies in Playwright in 2026 | BrowserStack
- How do I authenticate a proxy in playwright - Stack Overflow
FAQ
Does Playwright Support SOCKS5 Proxies?
Yes. Playwright supports HTTP, HTTPS, and SOCKSv5 proxies using the same proxy object, just with a different server prefix (socks5://).
Should I Set the Proxy Globally or Per Context?
Set it globally at browser launch when every page in your run shares one proxy; use per-context configuration when you need multiple simultaneous proxies, like parallel test sessions.
Why Isn't Playwright Sending My Proxy Credentials?
Playwright often waits for the proxy to issue a 407 Proxy Authentication Required challenge before sending the Proxy-Authorization header, a behavior detailed in a Playwright GitHub issue; if your proxy expects credentials upfront, the connection can fail.
How Do I Exclude Certain Hosts From the Proxy?
Use the bypass field with a comma-separated list, such as localhost,*.internal.example,192.168.*, to route those hosts directly instead of through the proxy.
Which Proxy Type Works Best for Web Scraping in Playwright?
Rotating residential proxies with geographic targeting generally lower block risk for large-scale scraping, while dedicated static ISP proxies suit login-heavy or account-based flows better.
