Configure TrueProxies with Puppeteer
Basic usage
Section titled “Basic usage”import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({ args: ['--proxy-server=http://YOUR_HOST:YOUR_HTTP_PORT'],});
const page = await browser.newPage();
await page.authenticate({ username: 'your_username', password: 'your_password',});
await page.goto('https://httpbin.org/ip');const content = await page.content();console.log(content);
await browser.close();Chrome does not send a username and password to a SOCKS5 proxy, and
page.authenticate only answers HTTP proxy challenges. To use SOCKS5, add the
machine’s public address to the IP whitelist
and connect without credentials. For username and password authentication,
use the HTTP tab.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({ args: ['--proxy-server=socks5://YOUR_HOST:YOUR_SOCKS_PORT'],});
const page = await browser.newPage();
await page.goto('https://httpbin.org/ip');const content = await page.content();console.log(content);
await browser.close();Residential IPv4 country targeting
Section titled “Residential IPv4 country targeting”await page.authenticate({ username: 'your_username-country-us', password: 'your_password',});Residential IPv4 sticky sessions
Section titled “Residential IPv4 sticky sessions”await page.authenticate({ username: 'your_username-session-abc123', password: 'your_password',});Multiple pages with different IPs
Section titled “Multiple pages with different IPs”const browser = await puppeteer.launch({ args: ['--proxy-server=http://YOUR_HOST:YOUR_HTTP_PORT'],});
const urls = ['https://example.com', 'https://example.org'];
for (const url of urls) { const page = await browser.newPage(); await page.authenticate({ username: 'your_username', password: 'your_password', }); await page.goto(url); console.log(`${url}: loaded`); await page.close();}
await browser.close();