Proxies + AI
Mobile Proxy Setup in Puppeteer (Node.js)
November 2026·7 min read·Puppeteer, Node.js
Puppeteer doesn't take a proxy object the way Playwright does. You pass the proxy address as a Chrome flag and send the username and password separately with page.authenticate(). Once you know that, a dedicated 4G/5G mobile proxy takes about five lines. This guide shows the setup, a different proxy per browser context, SOCKS5, and a check that every run really goes through the proxy.
1. Your proxy details
In the RelayKit dashboard, open a proxy under My Proxies and click 🤖 Use with AI tools → Puppeteer. You get the script below with your IP, port, username and password already filled in, plus a copy button. In this guide they're placeholders: YOUR_PROXY_IP, HTTP port 8000, SOCKS5 port 9000, USER and PASS.
Keeping them in environment variables makes it easy to update them later (for example after moving a Multi-Location proxy to another city):
Shell
export PROXY_HOST=YOUR_PROXY_IP PROXY_PORT=8000 PROXY_USER=USER PROXY_PASS=PASS
npm i puppeteer
2. Basic setup: HTTP proxy with a login
Chrome's --proxy-server flag has no place for a password, so Puppeteer answers the proxy's login challenge for you when you call page.authenticate(). Call it on every new page, before the first goto.
proxy-check.js
const puppeteer = require('puppeteer');
const { PROXY_HOST, PROXY_PORT = '8000', PROXY_USER, PROXY_PASS } = process.env;
(async () => {
const browser = await puppeteer.launch({
args: [`--proxy-server=http://${PROXY_HOST}:${PROXY_PORT}`],
});
const page = await browser.newPage();
await page.authenticate({ username: PROXY_USER, password: PROXY_PASS });
await page.goto('https://api.ipify.org?format=json', { timeout: 60_000 });
console.log(await page.evaluate(() => document.body.innerText)); // must show the proxy's IP
await browser.close();
})();
Don't put the login in the URL. --proxy-server=http://USER:PASS@host:8000 looks like it should work, but Chrome ignores credentials in that flag. Use page.authenticate().
3. SOCKS5 (with IP whitelisting)
RelayKit proxies also answer on SOCKS5 port 9000. Chromium can't send a username and password to a SOCKS5 proxy, and page.authenticate() doesn't help there. So in Puppeteer:
- With a username and password, use the HTTP port (section 2). That's the normal setup and it carries HTTPS traffic fine.
- For SOCKS5, turn on IP Whitelisting on the proxy card and add your machine's public IP. The proxy then accepts connections from that IP with no login, and SOCKS5 works:
SOCKS5, whitelist mode (no authenticate call)
const browser = await puppeteer.launch({
args: [`--proxy-server=socks5://${process.env.PROXY_HOST}:9000`],
});
const page = await browser.newPage();
await page.goto('https://api.ipify.org?format=json', { timeout: 60_000 });
The dashboard's Puppeteer snippet shows this SOCKS5 version only when whitelisting is on, for the same reason.
4. A different proxy per browser context
Puppeteer 22 and later can give each incognito browser context its own proxy, so one Chrome process can run several proxies side by side. Authenticate each page as usual.
One context per proxy
const PROXIES = [
{ server: 'http://PROXY_IP_A:8000', username: 'USER_A', password: 'PASS_A' },
{ server: 'http://PROXY_IP_B:8000', username: 'USER_B', password: 'PASS_B' },
];
const browser = await puppeteer.launch();
for (const p of PROXIES) {
const ctx = await browser.createBrowserContext({ proxyServer: p.server });
const page = await ctx.newPage();
await page.authenticate({ username: p.username, password: p.password });
await page.goto('https://api.ipify.org?format=json', { timeout: 60_000 });
console.log(p.server, '->', await page.evaluate(() => document.body.innerText));
await ctx.close();
}
await browser.close();
Multi-Location note: if what you need is several US cities rather than several IPs at the same moment, one RelayKit Multi-Location proxy covers it. Run the script, switch the proxy to another city on its card, update your environment variables from the card, and run again.
5. Verify the IP and city
Make the check a function and call it before the real work. If the proxy isn't in use, stop instead of collecting data from your own IP.
verify.js
async function whereAmI(page) {
await page.goto('https://ipapi.co/json/', { timeout: 60_000 });
const info = JSON.parse(await page.evaluate(() => document.body.innerText));
return { ip: info.ip, city: info.city, region: info.region, org: info.org };
}
const where = await whereAmI(page);
if (where.ip !== process.env.EXPECTED_IP) {
throw new Error(`Not on the proxy: saw ${where.ip}`);
}
Mobile IPs aren't static: Reset IP, an auto-rotation timer or a city switch gives you a new one. For rotating setups, check the city (and that org is the mobile carrier) instead of an exact IP.
6. Timeouts, retries and lighter pages
- Use 45–60 second navigation timeouts. A carrier connection has more latency than a datacenter line.
- Use
waitUntil: 'domcontentloaded' on tracker-heavy pages, then wait for the one selector you need. - Retry once on a timeout before failing the run.
- If you only need text, skip images, fonts and video:
Block heavy assets
await page.setRequestInterception(true);
page.on('request', req =>
['image', 'font', 'media'].includes(req.resourceType()) ? req.abort() : req.continue()
);
Retry once
async function gotoWithRetry(page, url) {
try {
return await page.goto(url, { timeout: 60_000, waitUntil: 'domcontentloaded' });
} catch (e) {
console.warn('retrying', url, e.message);
return page.goto(url, { timeout: 60_000, waitUntil: 'domcontentloaded' });
}
}
7. Example: the same check in several cities
A typical research job: record the prices a page shows to visitors in different cities. This script logs one JSON line per run with the city it actually ran from. Run it, switch your Multi-Location proxy to the next city in the dashboard, copy the new details into your environment, and run it again.
price-check.js
const puppeteer = require('puppeteer');
const fs = require('fs');
const { PROXY_HOST, PROXY_PORT = '8000', PROXY_USER, PROXY_PASS } = process.env;
const TARGET = 'https://example.com/pricing'; // the page you're researching
const PRICE_SELECTOR = '.price'; // adjust to the site
(async () => {
const browser = await puppeteer.launch({ args: [`--proxy-server=http://${PROXY_HOST}:${PROXY_PORT}`] });
const page = await browser.newPage();
await page.authenticate({ username: PROXY_USER, password: PROXY_PASS });
await page.goto('https://ipapi.co/json/', { timeout: 60_000 });
const where = JSON.parse(await page.evaluate(() => document.body.innerText));
await page.goto(TARGET, { timeout: 60_000, waitUntil: 'domcontentloaded' });
await page.waitForSelector(PRICE_SELECTOR, { timeout: 30_000 });
const prices = await page.$$eval(PRICE_SELECTOR, els => els.map(e => e.textContent.trim()));
const row = { city: where.city, region: where.region, ip: where.ip, prices, at: new Date().toISOString() };
fs.appendFileSync('prices.jsonl', JSON.stringify(row) + '\n');
console.log(row);
await browser.close();
})();
Only collect what you're allowed to: respect each site's terms and robots rules, keep request rates modest, and use the data for your own research, monitoring and QA.
Puppeteer on a dedicated US mobile IP
Real Verizon 4G/5G carrier IPs, unlimited data, HTTP and SOCKS5, and a Multi-Location plan that switches US cities from the dashboard. Pay with crypto; sign up with an email.
See the Multi-Location proxy →Related guides