Puppeteer and Playwright both drive Chromium, and both accept an authenticated HTTP proxy. This guide shows the setup for each with Dengz mobile proxies, then runs one browser context per country on the universal endpoint.
The examples read credentials from environment variables: DENGZ_HOST, DENGZ_PORT, DENGZ_USER and DENGZ_PASS. Replace them with the HOST, PORT, USER and PASS from your dashboard. IP_CHECK_URL is any page that returns your public IP as plain text.
Use HTTP, not SOCKS5, in Chromium
Dengz serves HTTP(S) and SOCKS5 on the same port by default. In a browser, use the HTTP scheme. Chromium does not support username and password authentication for SOCKS5 proxies, so a socks5:// proxy with credentials will fail. HTTPS sites still work over an HTTP proxy, because the browser opens a CONNECT tunnel.
One exception: dedicated proxies can authenticate by allowed source IP instead of a password. If your server's IP is on the allowlist, no credentials are needed, and SOCKS5 works too. The shared pool always requires credentials.
Puppeteer
Pass the proxy as a launch argument, then answer the auth challenge with page.authenticate. Save this as check-ip.mjs:
import puppeteer from 'puppeteer';
const { DENGZ_HOST, DENGZ_PORT, DENGZ_USER, DENGZ_PASS, IP_CHECK_URL } = process.env;
const browser = await puppeteer.launch({
args: [`--proxy-server=http://${DENGZ_HOST}:${DENGZ_PORT}`],
});
const page = await browser.newPage();
await page.authenticate({ username: `${DENGZ_USER}__fr`, password: DENGZ_PASS });
await page.goto(IP_CHECK_URL);
console.log('Exit IP:', await page.evaluate(() => document.body.innerText.trim()));
await browser.close();
The username suffix __fr picks France on the universal endpoint. Use __de, __es, __ch, __gb or __global for other countries.
Playwright
Playwright takes the credentials in the proxy object itself, so there is no separate auth step:
import { chromium } from 'playwright';
const { DENGZ_HOST, DENGZ_PORT, DENGZ_USER, DENGZ_PASS, IP_CHECK_URL } = process.env;
const browser = await chromium.launch({
proxy: {
server: `http://${DENGZ_HOST}:${DENGZ_PORT}`,
username: `${DENGZ_USER}__de`,
password: DENGZ_PASS,
},
});
const page = await browser.newPage();
await page.goto(IP_CHECK_URL);
console.log('Exit IP:', (await page.textContent('body')).trim());
await browser.close();
One context per country
Playwright can also set a proxy per browser context. With the universal endpoint, that gives you one browser process with a context per country, each with its own cookies and storage:
import { chromium } from 'playwright';
const { DENGZ_HOST, DENGZ_PORT, DENGZ_USER, DENGZ_PASS, IP_CHECK_URL } = process.env;
const countries = ['fr', 'de', 'es', 'ch', 'gb'];
const browser = await chromium.launch();
for (const country of countries) {
const context = await browser.newContext({
proxy: {
server: `http://${DENGZ_HOST}:${DENGZ_PORT}`,
username: `${DENGZ_USER}__${country}`,
password: DENGZ_PASS,
},
});
const page = await context.newPage();
await page.goto(IP_CHECK_URL);
console.log(country, (await page.textContent('body')).trim());
await context.close();
}
await browser.close();
Keep one thing in mind. On the shared pool, each new connection is served by a random ready modem of the chosen country. A browser opens several connections per page, so one page load can exit through more than one IP in that country. If your task needs a single stable IP for a whole session, use a dedicated mobile proxy, whose IP stays the same until you renew it.
To keep countries cleanly separated in Puppeteer, launch one browser per country, each with its own page.authenticate username.
Save bandwidth by skipping heavy resources
Mobile traffic is billed per GB, and images, fonts and video are usually most of a page's weight. If your task only needs the HTML or text, abort those requests. In Playwright:
const skip = new Set(['image', 'font', 'media']);
await page.route('**/*', (route) =>
skip.has(route.request().resourceType()) ? route.abort() : route.continue()
);
In Puppeteer, the same idea uses page.setRequestInterception(true) and a request handler that calls request.abort() or request.continue(). Check that the page still renders what you need before you roll this out.
Checking and troubleshooting
- 407 Proxy Authentication Required: check the username suffix and password, and that you used
http://, notsocks5://. - Wrong country: print the exit IP and look it up in the RIPE Database. The netname should point to a mobile network in that country.
- Timeouts: mobile links are slower than server links. Raise navigation timeouts before you add retries.
page.setDefaultNavigationTimeout(60000)works in both libraries.
For parallel work, run contexts concurrently with Promise.all instead of the loop above. On the shared pool each context's connections spread across modems of its country. On a dedicated modem, sessions are unlimited, but every context shares that modem's single IP, so parallel contexts look like one busy user. Size your concurrency to match what a real user of that IP could plausibly do.
More setups, including other libraries, are in the integrations docs. Start with the quick start if you do not have credentials yet.