Playwright proxy authentication, one static IP per context
Updated:
A Playwright proxy is configured with a proxy object holding server, username and password, and Playwright answers the proxy's 407 challenge itself, with no extension or wrapper. Set it on launch() to cover the whole browser, or on newContext() to give each isolated context a different ProxyV4 IP inside one browser process. The same keys work for Chromium, Firefox and WebKit, from Node.js or Python.
proxy={ server: 'http://ip:port', username: 'user', password: 'pass' }The proxy object, key by key
| Key | Example value | Notes |
|---|---|---|
server | 'http://ip:port' | Address and port only; credentials do not go in this string |
username | 'user' | The username from your ProxyV4 order |
password | 'pass' | Sent automatically when the proxy replies 407 |
bypass | 'localhost,127.0.0.1' | Optional list of hosts that should skip the proxy |
Browser-wide or per context
Passing proxy to chromium.launch() sends every page of that browser through one IP, which suits a single job with a single identity. Passing it to browser.newContext() is the multi-account pattern: each context has its own cookies, storage and proxy, so one Chromium process can hold several sessions that each show a different exit address.
Because every ProxyV4 private IPv4 is rented to one customer and keeps its address on renewal, you can map context names to IPs in config and reuse that mapping run after run; a site that saw account A on a given IP last week sees the same IP today.
Details that keep contexts consistent
- Some Playwright and Chromium combinations on Windows and macOS refuse per-context proxies unless the browser was launched with a proxy too; launch with the placeholder
proxy: { server: 'http://per-context' }and override it in each context - Set
timezoneIdandlocaleinnewContext()to match the proxy's country (for exampleAmerica/New_Yorkfor a US IP,Asia/Ho_Chi_Minhfor Vietnam), so the clock andIntloutput agree with the IP - Block images and fonts with
page.route()when you only need text; pages load faster and the run finishes sooner - Close contexts you no longer need; each one keeps its own connections open
Step by step
- 1
Split your proxy line
From the
ip:port:user:passline in your ProxyV4 order, takeip:portforserverand the last two fields forusernameandpassword. - 2
Create a context with the proxy
Call
const context = await browser.newContext({ proxy: { server: 'http://ip:port', username: 'user', password: 'pass' } }). - 3
Match time zone and language
Add
timezoneIdandlocalefor the proxy's location to the samenewContext()options. - 4
Load the IP endpoint
Open
const page = await context.newPage(), go tohttps://proxyv4.com/api/my-ipand check that the address shown is the proxy IP. Running a WebRTC leak test in the same context is a useful second check.
Frequently asked questions
Playwright says 'Proxy is only supported when browser is launched with a proxy'. How do I fix it?
On Windows and macOS, Chromium can require a launch-level proxy before it accepts per-context ones. Launch with chromium.launch({ proxy: { server: 'http://per-context' } }), then give each browser.newContext({ proxy }) the real address and login.
Does the same proxy setup work in Firefox and WebKit?
Yes. proxy: { server, username, password } is shared by all three engines and by the Node.js and Python APIs, so only the launcher (firefox, webkit) changes.
Will headless browsers use up a traffic quota?
Not on ProxyV4 private IPv4 or static ISP plans; bandwidth on both is unlimited, so heavy pages do not cost extra.
Pages fail with a tunnel error instead of loading. What should I check?
Confirm that server uses http:// and the right port, and that the proxy is still active in your dashboard. The tunnel connection guide covers the remaining causes.
One private IP per Playwright context
HTTP(S) proxies with user and password in 7 countries, unmetered, same address on renewal.
Check live US prices