Skip to main content
Puppeteer is a Node.js library for controlling headless Chrome. Here’s how to route your Puppeteer traffic through Stat Proxies.

Basic setup

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    args: ['--proxy-server=http://192.168.1.1:3128']
  });

  const page = await browser.newPage();

  // Authenticate with the proxy
  await page.authenticate({
    username: 'myuser',
    password: 'mypass'
  });

  await page.goto('https://httpbin.org/ip');
  const content = await page.content();
  console.log(content);

  await browser.close();
})();

Key steps

1

Pass the proxy server on launch

Use the --proxy-server flag in the args array when launching the browser. This sets the proxy at the browser level.
2

Authenticate on the page

Call page.authenticate() with your proxy username and password before navigating to any page.
3

Navigate normally

All requests from this browser instance will now route through your proxy.

Rotating through multiple proxies

To use different proxies for different tasks, launch separate browser instances:
const proxies = [
  { host: '192.168.1.1:3128', user: 'user1', pass: 'pass1' },
  { host: '192.168.1.2:3128', user: 'user2', pass: 'pass2' },
];

for (const proxy of proxies) {
  const browser = await puppeteer.launch({
    args: [`--proxy-server=http://${proxy.host}`]
  });
  const page = await browser.newPage();
  await page.authenticate({ username: proxy.user, password: proxy.pass });

  // Your automation logic here
  await page.goto('https://example.com');

  await browser.close();
}
Each browser instance maintains its own proxy connection. Close the browser and launch a new one to switch proxies.

Headless vs headful

// Headless (default) — faster, no visible window
const browser = await puppeteer.launch({
  headless: true,
  args: ['--proxy-server=http://192.168.1.1:3128']
});

// Headful — useful for debugging
const browser = await puppeteer.launch({
  headless: false,
  args: ['--proxy-server=http://192.168.1.1:3128']
});

Common issues

Verify that your proxy host and port are correct. Ensure the proxy is active in your dashboard.
Make sure you call page.authenticate() before navigating to any URL.
The --proxy-server flag only accepts host:port. Authentication must be done separately via page.authenticate().

Making Your First Request

Quick start code examples in multiple languages

Connection Errors

Diagnose and fix common proxy issues