Puppeteer proxy setup
Puppeteer sets the proxy when it launches Chrome and sends the login with page.authenticate. This guide covers both, a different IP per browser, saving bandwidth, and the errors you will see.
- Node.js
- Logins with page.authenticate
- Rotating or sticky IPs
Proxies for Puppeteer
Lowest rate for each. Every tier is on the pricing page.
Before you start
Three things to have ready.
Node.js and Puppeteer
Install with npm install puppeteer. It downloads a matching Chrome for you.
Your proxy line
Copy the host, port, username and password from the generator in your dashboard. The examples use Eternal Residential: et.vantixproxy.com, port 1000.
A test address
https://api.ipify.org returns the IP a request came from.
Step 1: Launch Chrome with a proxy
Pass the host and port with –proxy-server when the browser starts, then call page.authenticate before the first page load. Targeting goes at the end of the password.
- Flag –proxy-server sets host and port
- Login page.authenticate on each page
- Targeting In the password
- Whitelisted IP Skip page.authenticate
Node.js
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
args: ['--proxy-server=http://et.vantixproxy.com:1000'],
});
const page = await browser.newPage();
await page.authenticate({ username: 'USERNAME', password: 'PASSWORD_country-US' });
await page.goto('https://api.ipify.org');
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();
})();
Step 2: A different IP per browser
The proxy is fixed when Chrome starts. To run several IPs at once, start one browser per IP, each with its own session ID in the password.
One browser, one sticky IP
async function browserWithIp(sessionId) {
const browser = await puppeteer.launch({
args: ['--proxy-server=http://et.vantixproxy.com:1000'],
});
const page = await browser.newPage();
await page.authenticate({
username: 'USERNAME',
password: `PASSWORD_country-US_session-${sessionId}_lifetime-30`,
});
return { browser, page };
}
Step 3: Save bandwidth
Images, fonts and video are most of a page’s weight and are rarely needed for scraping. Block them and each page costs a fraction of the GB.
Block heavy resources
await page.setRequestInterception(true);
page.on('request', (req) => {
if (['image', 'font', 'media'].includes(req.resourceType())) req.abort();
else req.continue();
});
Troubleshooting and questions
What does ERR_TUNNEL_CONNECTION_FAILED mean?
Usually the login was rejected. Call page.authenticate before page.goto, and check the username and password, or whitelist your IP.
What does ERR_PROXY_CONNECTION_FAILED mean?
Chrome could not reach the proxy. Check the host and port for your product on the network status page.
Can I put the login in –proxy-server?
No. Chrome ignores a username and password in the flag. Use page.authenticate, or whitelist your IP.
Can I use SOCKS5 with Puppeteer?
Only without a login, because Chrome cannot log in to a SOCKS5 proxy. Use HTTP with page.authenticate, or socks5:// in the flag with a whitelisted IP.
Why does the IP stay the same across pages?
Chrome reuses connections to the same site, and a connection keeps the IP it started with. For a new IP, start a new browser or use a new session ID.
Which proxy is best for Puppeteer?
Budget Residential for scraping at volume. Eternal Residential for occasional runs. Premium Residential for sites that challenge ordinary residential IPs.
Related guides and tools
More setup guides, and tools to test your proxies.
Get proxies for Puppeteer
Budget Residential from $0.49/GB, or Eternal Residential from $0.75/GB that never expires. No KYC, crypto or card.