
Separate the proxy server flag from page credentials
Unlike Playwright, Puppeteer splits proxy routing across two places. You tell Chromium which proxy host and port to dial at launch or when creating a BrowserContext, then pass username and password per Page via page.authenticate().
Putting username:password directly inside Chromium's --proxy-server flag triggers connection errors or unexpected 407 prompts. Instead, pass the bare HTTP server URL (http://gate.ipmusk.com:31212 for IPMusk Rotating Residential, or your assigned host and port for Static ISP or Datacenter), read PROXY_USERNAME and PROXY_PASSWORD from environment variables, and authenticate each page before navigating:
- Keep credentials out of source code and supply country or available state parameters via your workspace Connect screen or build_proxy_url in MCP.
- IPMusk proxy lines authenticate via username and password only; IP allowlisting is not supported.
- Use HTTP proxy URLs when authenticating with page.authenticate(); headless Chromium's SOCKS5 client requires unauthenticated SOCKS5 endpoints.
import puppeteer from "puppeteer";
const { PROXY_USERNAME, PROXY_PASSWORD } = process.env;
if (!PROXY_USERNAME || !PROXY_PASSWORD) {
throw new Error("Set PROXY_USERNAME and PROXY_PASSWORD");
}
const browser = await puppeteer.launch({
args: ["--proxy-server=http://gate.ipmusk.com:31212"],
});
try {
const page = await browser.newPage();
await page.authenticate({
username: PROXY_USERNAME,
password: PROXY_PASSWORD,
});
const response = await page.goto("https://example.com/", {
waitUntil: "domcontentloaded",
timeout: 20_000,
});
if (!response) throw new Error("No navigation response");
console.log(response.status(), await page.title());
} finally {
await browser.close();
}Isolate routes with createBrowserContext and cut media traffic
Launching a dedicated Chromium instance for every region or proxy session burns RAM quickly. Puppeteer's Browser.createBrowserContext() accepts BrowserContextOptions with proxyServer and proxyBypassList, letting one browser process run isolated proxy routes side by side with separate cookies and storage.
When crawling text-oriented pages for RAG or price checks over metered residential bandwidth, pair per-context routing with request interception to abort images, fonts, and media streams:
| Puppeteer workload | Recommended IPMusk product | Key routing behavior |
|---|---|---|
| Public multi-page scraping, localization previews, and SERP checks | Rotating Residential (from $2.99 for 1 GB Trial; down to $0.80/GB at 1,000 GB) | Connects via gate.ipmusk.com:31212 with rotating or 1/3/10/30-min sticky exits and country/state targeting |
| Signed-in dashboards, persistent cookie sessions, or partner portals | Static ISP (Native ISP or ISP from $3.99/IP per 30 days) | Assigned dedicated IP with fixed host and port, unmetered traffic, and 30 or 90 day renewal |
| Permissive internal mirrors or uptime checks accepting hosting ASNs | Datacenter (from $2.99/IP per 30 days) | Lowest-cost unmetered assigned IP when destinations do not require residential ASNs |
import puppeteer from "puppeteer";
const { PROXY_USERNAME, PROXY_PASSWORD } = process.env;
if (!PROXY_USERNAME || !PROXY_PASSWORD) {
throw new Error("Set PROXY_USERNAME and PROXY_PASSWORD");
}
const browser = await puppeteer.launch();
const context = await browser.createBrowserContext({
proxyServer: "http://gate.ipmusk.com:31212",
proxyBypassList: ["localhost", "127.0.0.1"],
});
try {
const page = await context.newPage();
await page.authenticate({
username: PROXY_USERNAME,
password: PROXY_PASSWORD,
});
await page.setRequestInterception(true);
page.on("request", (req) => {
const type = req.resourceType();
if (type === "image" || type === "media" || type === "font") {
void req.abort();
return;
}
void req.continue();
});
const response = await page.goto("https://example.com/", {
waitUntil: "domcontentloaded",
timeout: 20_000,
});
console.log(response?.status(), await page.title());
} finally {
await context.close();
await browser.close();
}Always call page.authenticate() on new tabs or popups opened inside a proxied context, because authentication is bound per Page object rather than shared across pages automatically.
Verify exit IPs and catch 407, 403, and leak paths early
A silent direct connection can happen when proxyBypassList includes your test domain, when an older Chromium flag is overridden by container settings, or when a newly spawned target tab skips page.authenticate(). Check the exact address seen by the destination before scaling concurrency.
Open IPMusk's free IP Check tool (/tools/ip-check) inside the proxied Puppeteer page, or validate host, port, and login strings with /tools/proxy-checker before launching headless browsers:
- HTTP 407 Proxy Authentication Required: confirm you called await page.authenticate({ username, password }) before page.goto() and did not embed credentials inside --proxy-server (/blog/proxy-error-407).
- Second tab or popup fails auth: attach a targetcreated or popup listener on BrowserContext so newly opened pages receive authenticate() before navigation.
- HTTP 403 or 429 from target sites: inspect destination headers and rate limits (/blog/proxy-403-forbidden, /blog/proxy-429-too-many-requests) instead of retrying tight headless loops.
- Origin sees host IP instead of proxy: double-check proxyBypassList rules and confirm page requests did not trigger outside the proxied BrowserContext.
Sources checked
- Puppeteer LaunchOptions API reference: pptr.dev/api/puppeteer.launchoptions
- Puppeteer BrowserContextOptions interface (proxyServer, proxyBypassList): pptr.dev/api/puppeteer.browsercontextoptions and github.com/puppeteer/puppeteer
- Puppeteer Page.authenticate() and Credentials interface: pptr.dev/api/puppeteer.page.authenticate and pptr.dev/api/puppeteer.credentials
- IPMusk product pages and diagnostics: ipmusk.com/pricing/residential, ipmusk.com/pricing/isp, ipmusk.com/pricing/datacenter, ipmusk.com/tools/ip-check, and ipmusk.com/tools/proxy-checker
All API references, GitHub sources, and product pages verified HTTP 200 on December 3, 2026.
