No KYC — no ID, no selfie, no documents. Pay in crypto: BTC, USDT, USDC, ETH, SOL, LTC
Language: English
Get started

Docs · Playwright · Chromium, Firefox, WebKit · checked 13 November 2026

How do I use an authenticated proxy in Playwright?

Set the proxy at launch for one exit per browser, or per context for one country or one sticky session per context, then block what the scraper does not need.

Last updated: · 6 min read

Quick answer

How do I use an authenticated proxy in Playwright?

CrawlRelay works in Playwright through a proxy object with server http://gw.crawlrelay.com:7777 and the username and password in their own fields, passed to launch() or to each new context. Put the country and a session ID in the username to give each context its own exit for up to 30 minutes.

In brief
  • Option: proxy with server, username and password; credentials never inside the server URL.
  • Scope: launch() for the whole browser, new_context() or newContext() for one exit per context.
  • Port: HTTP 7777; Chromium has no SOCKS5 password support.
  • Traffic: a median page weighed 2,164 KB on mobile in 2025; blocking images, fonts and media cuts most of it.
  • Cost: $50 for 100 GB, $0.50/GB from 50 GB.

What does the Playwright setup look like at a glance?

What does the Playwright setup look like at a glance?
Proxy option{"server": "http://gw.crawlrelay.com:7777", "username": ..., "password": ...}
Wherelaunch(proxy=...) for the whole browser, or new_context(proxy=...) per context
PortHTTP port 7777; HTTPS sites go through CONNECT
SOCKS5Chromium does not support SOCKS5 authentication: use the HTTP port
One IP per context-session-<id>-ttl-<minutes> in the context's username
Typical page costAbout 2 MB with every resource; a few hundred KB with images, fonts and media blocked

How do I give each browser context its own country or session?

Create one browser context per country or per sticky session, each with its own proxy credentials. Contexts are cheap compared with browsers, and each keeps its own cookies, storage and proxy login. Match the context's locale to the exit country so the site sees a consistent visitor.

Python (sync API): one context per country
from playwright.sync_api import sync_playwright

GATEWAY = "http://gw.crawlrelay.com:7777"
LOCALES = {"us": "en-US", "de": "de-DE", "jp": "ja-JP"}

with sync_playwright() as p:
    browser = p.chromium.launch()
    for country, locale in LOCALES.items():
        context = browser.new_context(
            proxy={"server": GATEWAY, "username": "USERNAME-country-%s" % country, "password": "PASSWORD"},
            locale=locale,
        )
        page = context.new_page()
        page.goto("https://api.ipify.org", wait_until="domcontentloaded")
        print(country, page.inner_text("body"))
        context.close()
    browser.close()

How do I set the proxy in Playwright for Node.js and cut traffic?

The proxy option has the same shape in Node.js, and a route handler that aborts images, fonts and media removes most of a page's weight. The HTTP Archive Web Almanac 2025 measured a median page of 2,164 KB on mobile and 2,412 KB on desktop, most of it images, fonts and media. If the scraper only needs text and links, abort those requests before they leave the browser.

Node.js: sticky session at launch, heavy resources blocked
import { chromium } from "playwright";

const browser = await chromium.launch({
  proxy: {
    server: "http://gw.crawlrelay.com:7777",
    username: "USERNAME-country-us-session-pw1-ttl-30",
    password: "PASSWORD",
  },
});
const context = await browser.newContext();
// Images, fonts and media are most of a page's bytes
await context.route("**/*", (route) =>
  ["image", "font", "media"].includes(route.request().resourceType()) ? route.abort() : route.continue()
);
const page = await context.newPage();
const response = await page.goto("https://example.com/", { waitUntil: "domcontentloaded" });
console.log(response.status(), await page.title());
await browser.close();

How do I run many pages in parallel with asyncio?

Use the async API with a fixed pool of contexts, each holding one sticky session for its lifetime. A site then sees a few stable visitors rather than one IP per request. Recycle a context, with a new session ID, after a set number of pages or after an error.

Python (async API): a pool of sticky contexts
import asyncio
import uuid

from playwright.async_api import async_playwright

GATEWAY = "http://gw.crawlrelay.com:7777"
WORKERS = 4


async def worker(browser, queue):
    session = uuid.uuid4().hex[:10]
    context = await browser.new_context(proxy={
        "server": GATEWAY,
        "username": "USERNAME-country-us-session-%s-ttl-30" % session,
        "password": "PASSWORD",
    })
    page = await context.new_page()
    while not queue.empty():
        url = await queue.get()
        try:
            response = await page.goto(url, wait_until="domcontentloaded", timeout=45000)
            print(session, url, response.status if response else None)
        except Exception as exc:  # timeouts and network errors: log and move on
            print(session, url, type(exc).__name__)
        finally:
            queue.task_done()
    await context.close()


async def main(urls):
    queue = asyncio.Queue()
    for url in urls:
        queue.put_nowait(url)
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        await asyncio.gather(*(worker(browser, queue) for _ in range(WORKERS)))
        await browser.close()


asyncio.run(main(["https://example.com/", "https://example.org/"]))

Why do I get ERR_TUNNEL_CONNECTION_FAILED or ERR_PROXY_CONNECTION_FAILED?

The first means the gateway refused the CONNECT, usually for missing credentials; the second means the browser never reached the gateway. - net::ERR_TUNNEL_CONNECTION_FAILED: most often the credentials were written inside server instead of username and password, so Chromium sent none. See the tunnel error.

  • net::ERR_PROXY_CONNECTION_FAILED: a typo in the host or port, or a network that blocks the port.
  • Timeout 30000ms exceeded on goto usually means you wait for load or networkidle on a page that keeps loading trackers. Wait for domcontentloaded and then for the selector you need.

What should a Playwright scraper not do?

Render public pages that need JavaScript; do not use the browser to impersonate people. CrawlRelay's Acceptable Use Policy forbids sending browsers through the gateway to create accounts in bulk, take over accounts, solve CAPTCHAs automatically or defeat a site's deliberate blocks. CrawlRelay does not document stealth plugins or fingerprint spoofing. If a site challenges the browser, slow down, read its robots.txt and terms, and ask for access or use its API. The 403, 429 and CAPTCHA guide lists the responses that work.

How much traffic does a Playwright crawl use, and what does it cost?

Count every byte the browser downloads: HTML, scripts, styles, images, fonts and API calls are all billed. Sum response sizes in a response handler over 50 real pages to get your own figure; with heavy resources blocked, a page often drops to a few hundred kilobytes.

According to CrawlRelay's survey of 13 October 2026, the median residential price was $2.50/GB at 100 GB across 14 offers. CrawlRelay sells 100 GB for $50. At 300 KB per page, 100 GB covers roughly 333,000 rendered pages; at the full 2 MB, about 50,000.

Playwright and proxies: questions

Can I use a different CrawlRelay proxy for each Playwright context?

Yes. Pass proxy to browser.new_context() in Python or browser.newContext() in Node.js, with a different CrawlRelay username for each. Each context then has its own exit, cookies and storage.

Does Playwright support CrawlRelay SOCKS5 with a password?

Not in Chromium, which has no SOCKS5 password support. Use the CrawlRelay HTTP port 7777: it carries HTTPS sites through CONNECT tunnels in every engine Playwright drives.

How do I check which CrawlRelay IP a Playwright page uses?

Open https://api.ipify.org in the same context before the target and read the body text. A CrawlRelay sticky session keeps that IP only while its residential device stays online, so log the IP at the start of each context.

Headless or headed browsers with CrawlRelay?

Headless for servers, since it uses fewer resources; headed only to debug what a page shows. CrawlRelay bills the same per GB in both modes, and the same rules apply: public pages at a polite pace.

Verdict
  • Set the proxy per context whenever a crawl needs more than one country or session: one browser, many exits.
  • Block images, fonts and media on every scraping context: it can bring a 2 MB page down to a few hundred kilobytes, and the bill with it.
Sources (2)
  1. Web Almanac 2025, Page weight chapter (median 2,164 KB mobile, 2,412 KB desktop) — HTTP Archive (read 2026-11-13)
  2. Playwright network: HTTP proxy — Microsoft (read 2026-11-13)

Render public pages through residential IPs

$50 for 100 GB, enough for tens of thousands of rendered pages.

From $0.50/GB · no KYC

Get started