The One Thing to Know About a Patchright Proxy
Patchright is a patched drop-in replacement for Playwright — it patches Playwright's Chromium driver so the automated browser presents a more consistent, realistic fingerprint, but keeps the API identical. That's the whole point for proxy setup: you change one import and every proxy pattern you know from Playwright works unchanged.
So there's no new proxy API to learn. Patchright takes the server, username, and password together in one proxy object, exactly like Playwright:
chromium.launch({ proxy: { server: 'http://PROXY_HOST:PORT', username: 'USER', password: 'PASS' } });
No page.authenticate, no header injection, no credential parsing. Patchright reads the credentials from the object and hands them to the browser for you.
Patchright is a library for presenting a consistent browser so you can reach public data reliably — not a tool for defeating access controls. The other half of that reliability is the egress IP: a real German mobile IP with solid IP reputation is what a well-behaved crawler needs on German platforms. If you already run Playwright, this is a one-line change; see the Playwright setup for the shared pattern.
Before You Start
You need four values from your GermanProxy.io account:
- Host and port of your endpoint
- Username and password
The examples use PROXY_HOST, PORT, USER and PASS as placeholders — replace them with your own. Install Patchright. For Node:
npm install patchright
For Python:
pip install patchright
patchright install chromium
Step 1 — Launch Chromium Through the Proxy (Node)
This is the complete, runnable pattern. The only difference from Playwright is the require line — server, username, and password all go in the proxy object:
const { chromium } = require("patchright");
// From your GermanProxy.io account
const PROXY_HOST = "PROXY_HOST";
const PORT = "PORT";
const USER = "USER";
const PASS = "PASS";
(async () => {
const browser = await chromium.launch({
proxy: {
server: `http://${PROXY_HOST}:${PORT}`,
username: USER,
password: PASS,
},
});
const page = await browser.newPage();
await page.goto("https://www.example.de", { waitUntil: "domcontentloaded" });
console.log("Title:", await page.title());
await browser.close();
})();
Every request from page — HTML, XHR, fetch, images — now travels over your German mobile IP. No pool middleware, no extra dependency, no separate auth step.
Step 2 — The Same Setup in Python
Change the import to patchright.sync_api; the proxy object is identical to Playwright:
from patchright.sync_api import sync_playwright
PROXY_HOST = "PROXY_HOST"
PORT = "PORT"
USER = "USER"
PASS = "PASS"
with sync_playwright() as p:
browser = p.chromium.launch(
proxy={
"server": f"http://{PROXY_HOST}:{PORT}",
"username": USER,
"password": PASS,
}
)
page = browser.new_page()
page.goto("https://www.example.de", wait_until="domcontentloaded")
print("Title:", page.title())
browser.close()
Same four values, same one-object auth. Patchright's proxy API is Playwright's, so it's consistent across languages. sync_playwright here is imported from patchright, not playwright — that's the drop-in swap.
Step 3 — Per-Browser vs. Per-Context
You can set the proxy at two levels, just like Playwright:
- Per browser (launch): every context and page in that browser uses the proxy. This is the pattern above and the right default for a single dedicated endpoint.
- Per context (
newContext): scope the proxy to one context. Launch withproxy: { server: 'per-context' }, then give each context its own — useful when you run several isolated sessions in one browser.
const browser = await chromium.launch({ proxy: { server: "per-context" } });
const context = await browser.newContext({
proxy: {
server: `http://${PROXY_HOST}:${PORT}`,
username: USER,
password: PASS,
},
});
const page = await context.newPage();
With one dedicated German endpoint the launch-level form is simplest.
Step 4 — Verify the IP Before You Scale
Confirm you're actually on a German mobile IP before you build anything on top of it. Point the same page at an IP-echo endpoint and read the result:
await page.goto("https://api.ipify.org?format=json", {
waitUntil: "domcontentloaded",
});
const ip = await page.evaluate(() => document.body.innerText);
console.log("Egress IP:", ip);
If it returns your own address, re-check that the proxy object reached launch (or newContext) and that the server, username and password are all present. For a fuller checklist, see validating the proxy connection. A persistent 407 Proxy Authentication Required points at the credentials — see how to fix 407 proxy authentication required.
Step 5 — Check for WebRTC and DNS Leaks
A proxy routes Chromium's HTTP traffic, but the browser has two side channels that can expose your real address:
- WebRTC can surface your local IP via ICE candidates even with a proxy set — see what a WebRTC leak is.
- DNS can resolve names outside the tunnel depending on configuration — see what a DNS leak is.
For data-collection work in headless mode WebRTC is usually inert, but verify it for any flow where IP consistency matters. A real German mobile IP only helps if nothing else leaks past it — walk through both with how to check a proxy for leaks.
HTTP vs. SOCKS5 in Patchright
Both protocols come with your endpoint. Which to put in server depends on what you need:
| Aspect | HTTP endpoint | SOCKS5 endpoint |
|---|---|---|
| Server value | http://HOST:PORT |
socks5://HOST:PORT |
| Username/password auth in Chromium | Yes, via the proxy object |
No — Chromium has no SOCKS5 user/pass auth |
| Best auth mode | Credentials | IP allowlist |
| Typical use | Default for most scraping | Lower-level / non-HTTP traffic |
For most Patchright scraping, the HTTP endpoint with credentials in the proxy object is the simplest path. Patchright accepts socks5:// in server, but because the underlying Chromium can't authenticate a SOCKS5 proxy with a username and password, reach for SOCKS5 only when you specifically need it and can use IP-allowlist authentication. Background: SOCKS5 vs HTTP proxy.
Sticky Sessions vs. Rotation
With a dedicated German endpoint you control the IP at the proxy, not in your code:
- Sticky session: keep one browser (or one
newContext()) open across a multi-step flow — login, navigate, paginate — and the German mobile IP stays the same. - Rotation on demand: when you want a fresh IP, trigger rotation at the proxy and open a new context. There's no per-request IP pool to manage in Patchright.
This is why a dedicated endpoint keeps the code small: no rotation list, no health-checking, no retry-on-dead-IP loop. See sticky sessions and IP rotation explained and dedicated vs shared mobile proxy.
Why a Mobile IP for Patchright at All
Patchright, like Playwright, is a common choice for JavaScript-heavy pages that a plain HTTP client can't render — product pages, SERPs, dashboards. The catch is the egress IP: datacenter ranges are widely distrusted, so even a perfectly behaved crawler can hit friction. A real German mobile IP rides on carrier-grade NAT (CGNAT), the same shared-IP space thousands of ordinary phone users sit behind, which is why it carries higher IP reputation on German platforms — the point that matters more than any browser-side patch, since websites also detect proxies by the IP itself. A consistent TLS fingerprint (JA3/JA4) and a trusted IP work together, not one instead of the other.
For the trade-offs against other IP types, see mobile vs residential vs datacenter proxy and what is a mobile proxy.
Scrape Responsibly
A mobile proxy improves reliability for legitimate data collection — it is not a tool to circumvent access controls or platform rules. Keep your Patchright crawl clean and defensible:
- Respect each site's terms and its
robots.txt; collect only public data you're permitted to use. - Throttle with realistic delays between navigations so you don't overload servers — a full Chromium is heavier than a plain HTTP client.
- Collect only what you need, and handle any personal data in line with the GDPR. See scraping legality in the EU.
- Be honest about who you are — don't impersonate a service or misuse a target's security mechanisms.
Whether mobile proxies themselves are lawful to use: are mobile proxies legal.
FAQ
How do I set a proxy in Patchright?
Exactly like Playwright, because Patchright is a drop-in replacement. Pass it in the launch options: chromium.launch({ proxy: { server: 'http://PROXY_HOST:PORT', username: 'USER', password: 'PASS' } }). Patchright reads the credentials from that object, so there is no separate authenticate call.
Does Patchright use a different proxy API than Playwright?
No. Patchright patches Playwright's Chromium driver but keeps the API identical — you only change the import (patchright instead of playwright). The proxy option, with server, username and password together in one object, is the same in both. See the Playwright setup for the shared pattern.
How do I set a Patchright proxy in Python vs Node?
The proxy object is the same; only the surrounding syntax differs. In Python import from patchright.sync_api and pass proxy={'server': ..., 'username': ..., 'password': ...} to chromium.launch. In Node require chromium from 'patchright' and pass the equivalent proxy object.
Can Patchright use a SOCKS5 mobile proxy?
Yes, via server: 'socks5://PROXY_HOST:PORT'. But Chromium — which Patchright drives — cannot do SOCKS5 username/password auth, so a SOCKS5 endpoint works best with IP-allowlist authentication. For credential auth, use the HTTP endpoint. See SOCKS5 and HTTP compared.
Should I check for WebRTC and DNS leaks with Patchright?
Yes. The proxy routes HTTP traffic, but WebRTC can expose your real IP and DNS can resolve outside the tunnel. Verify both before you rely on the setup — see what a WebRTC leak is and what a DNS leak is.
Patchright or plain Playwright for a mobile proxy?
The proxy setup is identical either way. Patchright is a patched drop-in that makes an automated browser present a more consistent fingerprint for reaching public data; the real German mobile IP behind it is the other half of reliable access. If you're choosing, compare the Playwright setup and the Puppeteer setup.
Related guides
- Playwright Proxy Setup: Route via German Mobile IPs
- undetected-chromedriver Proxy Setup: German Mobile IPs
- nodriver Proxy Setup: Route Chrome via German Mobile IPs
CTA
Drive Patchright on real German mobile IPs. Get a German mobile proxy — HTTP/SOCKS5/OpenVPN, sticky sessions, on-demand rotation, fair-use 20 GB/day, from a transparent EU provider.
Get a German mobile proxy: Real 4G/5G IPs from Germany, fair-use 20 GB/day — browse German mobile proxy plans or get a dedicated proxy on the Blue network.