Regional Preferences

Language

Nothing in the list matches what you typed there.

Setup · 2026-06-13 · Updated

Playwright proxies made simple (Python and Node.js)

Playwright takes a proxy server, username and password as plain settings, in Python or Node.js. Use one proxy for the whole browser, or a different one per session.

In plain English: Playwright is a tool for controlling browsers from code. One set of commands drives Chromium (the engine behind Chrome and Edge), Firefox and WebKit (the engine behind Safari), and you can write your scripts in Python or Node.js. Its proxy support is refreshingly simple: the server, username and password are ordinary settings, so there's no extension to build and no login pop-up to fight.

Quick start in 3 steps

  1. Install Playwright and its browsers: one command for the package, one for the browsers.
  2. Check your proxy details with a one-line cURL test.
  3. Paste the launch example for your language, fill in your details and run it; the output shows the address the site saw.

Getting Playwright installed

Using Python:

pip install playwright
playwright install

Using Node.js:

npm install playwright
npx playwright install

The second command in each pair downloads the browsers that Playwright drives, so give it a minute. Wherever the code shows HOST, PORT, USER or PASS, put your own details. Test them before any browser code gets involved:

curl --proxy http://USER:PASS@HOST:PORT https://api.ipify.org

One proxy for the whole browser (Python)

Hand a proxy dictionary, a small set of labelled values, to launch(). The server, username and password each get a field of their own:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        headless=True,
        proxy={
            "server": "http://HOST:PORT",
            "username": "USER",
            "password": "PASS",
        },
    )
    page = browser.new_page()
    page.goto("https://api.ipify.org")
    print(page.content())
    browser.close()

Playwright answers the proxy's login request by itself, so the page simply loads.

The same thing in Node.js

The JavaScript version reads almost the same:

const { chromium } = require("playwright");

(async () => {
  const browser = await chromium.launch({
    headless: true,
    proxy: {
      server: "http://HOST:PORT",
      username: "USER",
      password: "PASS"
    }
  });

  const page = await browser.newPage();
  await page.goto("https://api.ipify.org");
  console.log(await page.content());
  await browser.close();
})();

A different proxy for each session

Playwright can also give each browser context its own proxy. A context is like a fresh private window with its own cookies and storage, so several can run inside one browser without mixing up their logins. Here, each context leaves through a different endpoint:

from playwright.sync_api import sync_playwright

endpoints = [
    {"server": "http://HOST:PORT1", "username": "USER", "password": "PASS"},
    {"server": "http://HOST:PORT2", "username": "USER", "password": "PASS"},
]

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    for ep in endpoints:
        ctx = browser.new_context(proxy=ep)
        page = ctx.new_page()
        page.goto("https://api.ipify.org")
        print(page.inner_text("body"))
        ctx.close()
    browser.close()

Got one rotating gateway rather than a list? Point every context at that gateway, and each session comes out on a new IP address without any extra code.

HTTP or SOCKS5?

The server field starts with the proxy type: http://HOST:PORT for HTTP, or socks5://HOST:PORT for SOCKS5. Playwright's username and password fields are meant for HTTP proxies, and a SOCKS5 proxy that needs a login won't work that way. So if you sign in with a username and password, stay with the http:// form. It still copes with secure https sites by opening a tunnel to them (the CONNECT method).

Make your data go further

Every gigabyte you route counts towards your plan, so the less a page downloads, the further your data stretches. Playwright's routing feature can stop images, video and fonts from loading:

page.route("**/*", lambda route: (
    route.abort()
    if route.request.resource_type in ["image", "media", "font"]
    else route.continue_()
))

Check before you scale up

Each example prints what the website sees as your IP address, so make sure it's the proxy's. For extra confidence, test the same details in our proxy checker and look up your real address with the My IP tool to compare the two.

Which type should I pick?

Read about every type on the proxies page, and see what each costs on the pricing page.

Common mistakes

  • Skipping the browser download. Without the second install command, Playwright has no browser to start.
  • Writing the login into the server address. Use the separate username and password fields.
  • socks5:// with a username and password. Switch to http:// for proxies that need a login.
  • Leaving contexts open. Close each one when it's finished, as the example does, so memory doesn't fill up.

Is this allowed?

Automated browsers can overwhelm a site if you're careless. Read the target's robots.txt, follow its terms of service, leave deliberate pauses between actions, and gather only public information you're permitted to collect. Never use Playwright to get round logins, beat anti-fraud measures or harvest personal information without a lawful basis. Polite automation protects your project and the proxy addresses you rely on.

Beginner questions

Python or Node.js: which should I use?

Whichever you already know. The proxy settings are the same in both.

Do I need all three browsers?

No. The install command fetches them all by default, but you can name a single browser to save disk space, and the examples above only use Chromium.

Does the per-context proxy work in Node.js too?

Yes. Browser contexts accept a proxy setting in both languages; the example above happens to be in Python.

Keep reading

Ready to try one yourself?

Start small: buy a little data in the type that suits your task, check it with our free tools, and top up only if you need more. There’s no contract and no minimum spend.

View our proxies

New to proxies? Start with a small order

Datacenter proxies cost $2.49 per gigabyte (GB) of data you use, so trying one on the site you care about needn’t cost much. Your login details are ready within seconds, and if you get stuck, a real person answers questions 24/7.

Budget Proxies logo

or
Continue with Email

Continue and you're agreeing to our Terms and Privacy Policy.

Already set up with us?

First time with us?

🎉 Money-off code

Knock 10% off
your next order

Type your email below and we’ll send the code over. It works on any proxy plan, however small the order. At checkout, paste it into the Promo code box and press Apply.

You’ll get the code and, now and then, an offer by email. Changed your mind later? Ask us and we’ll take you off the list.

Sorted! It’s on its way 📬

Your 10% code is heading to your inbox. No need to wait for the email, though: copy it from here and paste it in when you check out.

See residential plans →