Quick answer
How do I use an authenticated proxy in Puppeteer?
CrawlRelay works in Puppeteer in two steps: launch Chrome with --proxy-server=http://gw.crawlrelay.com:7777, then call page.authenticate() with your username and password before the first goto. Chrome ignores credentials written into the flag. A session ID in the username keeps one exit per context for up to 30 minutes.
In brief
- Address: --proxy-server in args, or proxyServer on a browser context; scheme, host and port only.
- Credentials: page.authenticate({ username, password }) on every new page, before navigating.
- Sessions: one browser context per sticky session, with its own country and session ID.
- SOCKS5: Chrome has no SOCKS5 password support; use port 7777.
- Cost: $3.75 for 5 GB of residential traffic; rotating mobile from $1.50/GB from 5 GB.
What does the Puppeteer setup look like at a glance?
| Proxy address | --proxy-server=http://gw.crawlrelay.com:7777 in args, or proxyServer on a browser context |
|---|---|
| Credentials | await page.authenticate({ username, password }) before navigating |
| Separate sessions | browser.createBrowserContext({ proxyServer }): one context per session |
| SOCKS5 | Not with authentication in Chrome: use the HTTP port |
| Saving traffic | page.setRequestInterception(true) and abort images, fonts and media |
How do I set up a single authenticated proxy?
Pass the gateway in args, call page.authenticate() and wrap the work in try … finally so Chrome always closes. This is the minimal pattern. Closing the browser even when a navigation fails matters on servers, where orphan Chrome processes pile up and hold memory.
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({
args: ["--proxy-server=http://gw.crawlrelay.com:7777"],
});
try {
const page = await browser.newPage();
await page.authenticate({ username: "USERNAME-country-us", password: "PASSWORD" });
await page.setRequestInterception(true);
page.on("request", (req) =>
["image", "font", "media"].includes(req.resourceType()) ? req.abort() : req.continue()
);
const res = await page.goto("https://example.com/", { waitUntil: "domcontentloaded", timeout: 60000 });
console.log(res.status(), await page.title());
} finally {
await browser.close();
}How do I run several sessions or countries in one browser?
Create one browser context per session, each with its own username, country and session ID. A context is an isolated profile with its own cookies, cache and network state, so the credentials given to one context do not leak into another.
import puppeteer from "puppeteer";
import { randomUUID } from "node:crypto";
const GATEWAY = "http://gw.crawlrelay.com:7777";
const browser = await puppeteer.launch();
async function visit(country, url) {
const session = randomUUID().replaceAll("-", "").slice(0, 10);
const context = await browser.createBrowserContext({ proxyServer: GATEWAY });
try {
const page = await context.newPage();
await page.authenticate({
username: `USERNAME-country-${country}-session-${session}-ttl-20`,
password: "PASSWORD",
});
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 60000 });
return { country, session, ip: await page.evaluate(() => document.body.innerText.trim()) };
} finally {
await context.close();
}
}
try {
const results = await Promise.all([
visit("us", "https://api.ipify.org"),
visit("gb", "https://api.ipify.org"),
]);
console.table(results);
} finally {
await browser.close();
}Why does Puppeteer show a 407 or ERR_TUNNEL_CONNECTION_FAILED?
Chrome sent no credentials, or the wrong ones, when it opened the CONNECT tunnel. Check three things:
page.authenticate()runs before the firstgotoon that page.- The
--proxy-serverflag orproxyServerholds only the scheme, host and port, with nouser:pass@part. - The username has no typo in its targeting part: test it with curl first, as shown on the 407 page.
If curl succeeds with the same username and password and Puppeteer still fails, read ERR_TUNNEL_CONNECTION_FAILED.
How much traffic does a Puppeteer page cost?
Everything Chrome downloads is billed, and a full page weighed 2,164 KB on mobile at the median in 2025. That figure, from the HTTP Archive Web Almanac 2025, rises to 2,412 KB on desktop. The HTML, scripts, styles, images, fonts and the page's own API calls all count. Blocking images, fonts and media with request interception usually cuts a page to a few hundred kilobytes, and serving repeated scripts from a local cache cuts it further.
According to CrawlRelay's survey of 13 October 2026, the median residential price was $3.88/GB at 5 GB across 12 offers. CrawlRelay sells 5 GB for $3.75, and $0.50/GB from 50 GB.
When should Puppeteer use mobile IPs instead of residential ones?
Use rotating 4G/5G mobile IPs only for pages whose content changes for phone users; use residential IPs for everything else. Mobile traffic costs $1.50/GB from 5 GB, residential $0.50/GB from 50 GB, so a browser crawl that sends every page through mobile exits pays three times the residential rate for the same bytes.
Typical mobile cases are a mobile-only landing page, an ad shown on carrier networks, or a check of what an app's web view loads. The mobile proxies page explains the shared 4G/5G pool, its country targeting and its rotation per new connection. The Puppeteer code stays the same: only the username and the plan change.
Does CrawlRelay support stealth plugins for Puppeteer?
No: CrawlRelay neither documents nor supports tools built to hide automation or defeat bot detection. Their purpose is to get past a site's decision to filter automated visitors, which the CrawlRelay Acceptable Use Policy does not allow. Render public pages at a polite pace, honour robots.txt, and use official APIs where sites provide them.
Puppeteer and proxies: questions
Can I put my CrawlRelay username and password in --proxy-server?
No. Chrome ignores credentials in the flag, and the first HTTPS request then fails with a 407 hidden behind ERR_TUNNEL_CONNECTION_FAILED. Put only the CrawlRelay host and port in the flag and call page.authenticate() on every new page.
How do I rotate the CrawlRelay IP between Puppeteer pages?
Open each page in a new browser context, or use a username without a session ID. CrawlRelay gives each new connection an IP from the pool, usually a different one; inside one page, Chrome reuses connections, so requests often share an exit.
Does page.authenticate() work with request interception on CrawlRelay?
Yes. Puppeteer answers the CrawlRelay authentication challenge itself, and the interception handler only calls continue() or abort(). Call authenticate() first, then turn interception on, as in the first example.
Which Chrome does Puppeteer use with CrawlRelay?
Recent Puppeteer versions download a matching Chrome for Testing build and use it by default. The CrawlRelay proxy flag and page.authenticate() behave the same there as in regular Chrome.
Verdict
- Use one browser context per session with page.authenticate(): it is the Puppeteer pattern that keeps several CrawlRelay exits apart in one Chrome.
- Switch to Playwright if you start a new project: it takes the username and password directly, with no extra call per page.
Sources (2)
- Web Almanac 2025, Page weight chapter — HTTP Archive (read 2026-11-13)
- Puppeteer API: Page.authenticate() — Puppeteer (read 2026-11-13)
Run Puppeteer through residential IPs
$3.75 for 5 GB to build, $25 for 50 GB in production.