Playwright Guide · 1 min read

Playwright proxy configuration guide

Playwright makes proxies first-class: one proxy object with server, username and password, set at the browser or the context level. Here is the clean setup for authenticated s4m proxies in both Python and Node.

One proxy object, two scopes

Unlike Puppeteer, Playwright accepts credentials directly in its proxy option, so there is no separate authenticate step. The object takes three fields: server (the host and port, with scheme), plus username and password. Playwright answers the proxy's 407 challenge for you.

You can set that object at two scopes. Passing it to browser_type.launch(proxy=...) applies one proxy to the whole browser. Passing it to browser.new_context(proxy=...) scopes the proxy to a single context — which is how you run several identities, each with its own exit, inside one browser. For s4m, use server="http://proxy.s4m.online:3128" with your USER:PASS; the HTTP endpoint is the dependable choice for browsers. Playwright also supports SOCKS5 via socks5://proxy.s4m.online:1080, though authenticated SOCKS5 in a browser is best avoided. More on the proxy page and in the Puppeteer guide.

Playwright with an authenticated proxy

Python and Node, both setting server + username + password. Context-level scope lets each context use its own exit.

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

PROXY = {
    "server": "http://proxy.s4m.online:3128",  # HTTP endpoint
    "username": "USER",
    "password": "PASS",
}

with sync_playwright() as p:
    # Option A: proxy for the whole browser
    browser = p.chromium.launch(proxy=PROXY, headless=True)

    # Option B: proxy scoped to a single context (per-identity)
    context = browser.new_context(proxy=PROXY)
    page = context.new_page()
    page.goto("https://api.ipify.org?format=json", timeout=30000)
    print("Exit IP:", page.inner_text("body"))
    browser.close()

# ----- Node equivalent -----
# const { chromium } = require("playwright");
# const proxy = {
//   server: "http://proxy.s4m.online:3128",
//   username: "USER", password: "PASS",
// };
# (async () => {
//   const browser = await chromium.launch({ proxy, headless: true });
//   const page = await browser.newPage();
//   await page.goto("https://api.ipify.org?format=json");
//   console.log(await page.innerText("body"));
//   await browser.close();
// })();

Set it up

From install to a verified proxied run.

Install browsers

Run pip install playwright then playwright install chromium (or npm i playwright). Playwright downloads its own browser build, so no system Chrome is required.

Build the proxy object

Set server to http://proxy.s4m.online:3128 and fill username and password with your s4m credentials. No separate authenticate call is needed.

Choose a scope

Pass proxy to launch() for a browser-wide exit, or to new_context() when you want each context to use its own IP for multiple identities.

Confirm the exit

Navigate to an IP-echo endpoint and read the body to verify the traffic is really leaving through the proxy before you build the rest of the flow.

Per-context identities and honest limits

Context-level proxies are Playwright's superpower for automation at scale: one browser process, many contexts, each isolated with its own cookies and its own exit IP. That is cleaner and lighter than launching a browser per identity. Pair it with distinct User-Agent and viewport settings per context so each identity is internally consistent.

The same honesty applies as everywhere else. s4m proxies are datacenter SOCKS5 and HTTP — fast and stable, ideal for testing and monitoring, but not disguised as home connections, so heavily defended sites can flag them. A proxy changes your IP, not your browser fingerprint or your behaviour, so treat it as one layer among several. When a service expects a single stable address, add a dedicated personal IP. Check exits and ports with the tools, explore the API, and test cheaply first with the free proxy list.

FAQ

Questions, answered

Do I need a separate authenticate step in Playwright?

No. Unlike Puppeteer, Playwright takes username and password directly in its proxy object, alongside server. It handles the 407 challenge for you automatically.

Can I give each context its own proxy?

Yes. Pass a proxy object to browser.new_context(proxy=...) and that context uses its own exit. This is the clean way to run multiple identities inside one browser.

Should I use the HTTP or SOCKS5 endpoint?

For browsers, use the HTTP endpoint on port 3128 — it is the dependable choice. Playwright supports SOCKS5 too, but authenticated SOCKS5 in a browser is best avoided.

Are s4m proxies residential?

No. They are authenticated datacenter SOCKS5 and HTTP proxies, metered pay-as-you-go. Great for testing and monitoring, though aggressive anti-bot systems may flag datacenter ranges.

Automate browsers behind a proxy

Drop proxy.s4m.online straight into Playwright's proxy object, scope it per context, and pay only for the traffic you use. Add a dedicated IP for stable, per-identity exits.

People found this page by searching for

Real search phrases this page answers — the linked ones open the page that covers them in depth.