Change language
English Русский Deutsch Español Français Italiano Українська Tiếng Việt Türkçe Bahasa Indonesia हिन्दी 日本語 中文
Menu
Pricing
Proxies
Solutions
Resources

How to use a proxy with Playwright

Give Playwright one static ISP address, at launch or for a single browser context. The samples were run in Chromium, Firefox and WebKit against a local proxy before they were published.

In short: Pass proxy with server, username and password to chromium.launch, or to browser.new_context to scope it to one context. Over HTTP, all three engines authenticate with those fields. Over SOCKS5 none of them accepts a username and password: Playwright refuses to launch. Put your IP on the proxy’s whitelist and give only the socks5:// server.

Playwright drives Chromium, Firefox and WebKit through one API, and the proxy is part of how a browser or a context is created. That makes it easy to run several addresses in one script, and it is also where its one hard limit sits: SOCKS5 with a password.

Playwright proxy in Python

The Python sample launches Chromium with the proxy for the whole browser; the per-context sample scopes it to one context instead. Switching the engine is changing chromium to firefox or webkit; the proxy object stays the same.

Playwright proxy authentication

The three engines answer the proxy’s 407 with the username and password from the proxy object when the proxy speaks HTTP. A SOCKS5 proxy gets no such answer from any of them, which is why the SOCKS5 sample carries no credentials and relies on the whitelist.

Playwright proxy per page, and bypass

A proxy cannot be attached to a single page. The unit is the context: create one context per address and open the pages that should share that address inside it. Contexts are cheap in Playwright, so a script that checks one storefront from three countries holds three contexts, each built from its own order.

The proxy object also takes a bypass field, a comma-separated list of hosts that should be reached directly. Use it for your own internal services or a local test server, so that only the traffic meant for the outside world leaves through the address you pay for.

Set a proxy in Playwright

  1. Copy host, port, username and password

    From My Proxies in the dashboard or the order in the API. Every address comes with its own four values.

  2. Choose the scope

    At launch the whole browser uses the proxy. On new_context only that context does, so one script can run several contexts through different addresses.

  3. Pass the proxy object

    {"server": "http://HOST:PORT", "username": "USERNAME", "password": "PASSWORD"}. The credentials go in their own fields, never inside the server URL.

  4. Going SOCKS5? Drop the credentials

    Playwright cannot log in to a SOCKS5 proxy, so switch the order to SOCKS5, admit your machine’s IP with the whitelist call in the code tabs, and keep only socks5://HOST:PORT, using the new port. While a whitelist is set, the proxy admits only the listed addresses and the username and password stop working for that order; sending an empty list turns the whitelist off and password login works again.

  5. Confirm the exit address

    Open What Is My IP in a page of that browser or context once, before the real run.

# pip install playwright && playwright install chromium
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(proxy={
        "server": "http://HOST:PORT",
        "username": "USERNAME",
        "password": "PASSWORD",
    })
    page = browser.new_page()
    page.goto("https://example.com/")
    print(page.title())
    browser.close()
// npm i playwright && npx playwright install chromium
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({
    proxy: {
      server: 'http://HOST:PORT',
      username: 'USERNAME',
      password: 'PASSWORD',
    },
  });
  const page = await browser.newPage();
  await page.goto('https://example.com/');
  console.log(await page.title());
  await browser.close();
})();
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    # The proxy belongs to this context only; another context can use
    # a different address, or none.
    context = browser.new_context(proxy={
        "server": "http://HOST:PORT",
        "username": "USERNAME",
        "password": "PASSWORD",
    })
    page = context.new_page()
    page.goto("https://example.com/")
    print(page.title())
    browser.close()
# Switch the proxy to SOCKS5 and put your machine's IP on its whitelist:
# Chromium cannot send a SOCKS5 username and password.
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(proxy={"server": "socks5://HOST:PORT"})
    page = browser.new_page()
    page.goto("https://example.com/")
    print(page.title())
    browser.close()
# Put the public IPv4 address your code runs from on the proxy's
# whitelist. Replaces the list; an empty list turns whitelisting off
# and the proxy falls back to username and password.
curl -X PUT "https://api.proxyjam.com/public/v1/orders/ORDER_ID/whitelist" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"whitelisted_ips": ["YOUR_IP"]}'

Tested code for Playwright

Run with Playwright 1.64 for Python and for Node. The HTTP samples send a username and password and need an order with no whitelist set; the SOCKS5 one relies on the whitelist and needs the proxy switched to SOCKS5 first, which gives a new port. Replace the capitals with your order's values.

Full API docs

What each Playwright browser accepts

Tested on 2026-10-22 with Playwright 1.64 for Python on macOS: each engine was launched against a local proxy that demanded a password, and against one that admitted a whitelisted client. Refused means Playwright stopped at launch with an error.
HTTP with passwordSOCKS5 with passwordSOCKS5, whitelisted
ChromiumWorksRefused at launchWorks
FirefoxWorksRefused at launchWorks
WebKitWorksRefused at launchWorks

What goes wrong with Playwright proxies

Credentials in the server string

Playwright reads the username and password from their own fields. Written into the server URL instead, they are not sent at all: in our test the first navigation hung until it timed out, with no message that pointed at the credentials.

A SOCKS5 password

Every engine refuses SOCKS5 authentication, and the error arrives at launch, before any page opens. The fix is not a different library: whitelist the IP your script runs from and drop the credentials.

Expecting new_page to change the address

Pages share the proxy of their context, and contexts share the browser's unless given their own. To run two addresses side by side, create two contexts, each with its proxy.

Skipping the exit check

A typo in the port or a proxy still set to HTTP fails loudly, but a context created without the proxy object goes out directly and silently. Load an IP echo page once per context you configure.

How the address fits Playwright's model

One context, one address
Each browser context can carry its own static IP from its own order
HTTP sign-in
username and password fields, accepted by Chromium, Firefox and WebKit
SOCKS5 sign-in
By whitelisted IPv4 address only, set through the API or MCP
Stability
The IP stays the same across runs for the whole period you paid for

Next steps from Playwright

Questions about proxies in Playwright

How do I set a proxy with authentication in Playwright?

Pass an object with server, username and password, either to launch or to new_context. Over an HTTP proxy, Chromium, Firefox and WebKit all send those credentials when the proxy asks for them.

Can I use a SOCKS5 proxy with a password in Playwright?

No. Playwright stops at launch with an error saying the browser does not support SOCKS5 proxy authentication, in all three engines. Whitelist the IP your script runs from, then pass only the socks5 server; our whitelist applies over SOCKS5 as well as HTTP. SOCKS5

How do I use a different proxy for each page?

Give each browser context its own proxy and open the page in that context. Pages inside one context always share its proxy, so per-page proxies mean one context per page.

Is the setup the same in Python and in Node?

The same object with the same three fields: Python writes it as a dictionary, Node as an object literal. Both samples on this page were run with Playwright 1.64.

Can I use the proxy for scraping?

Testing your own pages by region, quality checks, ad verification, price and market research, SEO monitoring and brand protection run without prior review under our acceptable use policy. Public availability alone does not authorise collecting data, personal data needs a stated lawful basis, and the address does not get past CAPTCHAs, bot detection, rate limits or bans; the policy forbids trying. Acceptable Use Policy

Contexts and static addresses map one to one: a context per market or per job, each reaching the target from an unchanged IP every time the script runs. Buy as many addresses as you run contexts on ISP proxies, compare plans on pricing, and fetch without a browser through the Python requests guide.

Sources