Puppeteer Proxy: How to Configure and Use Proxies with Puppeteer

Published:

June 30, 2025

Updated:

June 30, 2025

7

min read

joosep seitam

Joosep Seitam

Founder

Table of Contents

puppeteer proxy

Puppeteer is a robust Node.js library developed by Google’s Chrome DevTools team that allows developers to control Chrome or Chromium browsers through a high-level API. It is frequently used for tasks such as automated UI testing, generating PDFs, or scraping dynamic content from modern JavaScript-heavy websites.

However, when used for large-scale automation or scraping projects, Puppeteer can quickly trigger IP bans or rate-limiting mechanisms. To address these limitations, integrating proxies with Puppeteer is essential. Proxies allow requests to be routed through alternative IP addresses, enabling better anonymity, bypassing restrictions, and supporting geo-specific testing. This guide outlines the practical methods for configuring and using proxies with Puppeteer, covering everything from basic setup to advanced proxy rotation and troubleshooting.

What is a Puppeteer Proxy?

A Puppeteer proxy refers to a standard proxy server that routes traffic from a Puppeteer-controlled browser. Instead of making direct requests to a target website, Puppeteer sends those requests through the proxy, which then forwards them to the destination using its own IP address. The response follows the same route in reverse.

This setup enables two main advantages: masking the true IP of the automation environment and bypassing IP-based restrictions. While a single proxy can be assigned during browser launch, more advanced implementations allow for proxy rotation on a per-page or per-request basis, enhancing control and flexibility.

Why Use Proxies with Puppeteer?

why use proxies with puppeteer

Enhanced Privacy and Security

Proxies conceal the original IP address of the machine running Puppeteer, which prevents websites from tracing automated activity back to a specific server or individual. This protects the IP reputation of the server and avoids blanket bans that could impact other applications. Additionally, using proxies allows developers to isolate the automated tasks from their core infrastructure.

Avoiding Rate Limits and Blocks

Most websites implement anti-bot systems that track request frequency by IP address. Once a threshold is crossed, the system may impose temporary blocks or permanent bans. By using a pool of rotating proxies, each request appears to come from a different source, effectively distributing the load and reducing the likelihood of detection.

Geo-Specific Testing and Web Scraping

Proxies allow Puppeteer to simulate browsing from various geographic locations. This is essential for scraping region-specific content, verifying localized advertisements, or testing user experiences across different countries. For example, a residential proxy with an IP address from France can be used to test how a site appears to French users or to access country-restricted media.

How to Set Up Puppeteer to Use a Proxy

Basic Configuration for Puppeteer Proxy Server

To set up a proxy in Puppeteer, pass the --proxy-server argument when launching the browser. This directs all traffic through the specified proxy.

Steps:

  1. Install Puppeteer with npm i puppeteer

  2. Use the --proxy-server flag in puppeteer.launch() options

Example:


const puppeteer = require('puppeteer');
const PROXY_SERVER = 'http://160.86.242.23:8080';

(async () => {
  const browser = await puppeteer.launch({
    args: [`--proxy-server=${PROXY_SERVER}`],
  });

  const page = await browser.newPage();
  await page.goto('https://httpbin.org/ip');
  const ip = await page.evaluate(() => JSON.parse(document.body.textContent).origin);
  console.log(`IP: ${ip}`);

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

  
Copy

Using Authenticated Puppeteer Proxies

Authenticated proxies require credentials and cannot be passed in the URL due to Chromium’s restrictions. Instead, use page.authenticate().

Steps:

  1. Launch the browser with the proxy host and port only.

  2. Call page.authenticate() with credentials before navigation.

Example:


const puppeteer = require('puppeteer');
const PROXY_SERVER = 'brd.superproxy.io:33335';
const PROXY_USERNAME = 'your_username';
const PROXY_PASSWORD = 'your_password';

(async () => {
  const browser = await puppeteer.launch({
    args: [`--proxy-server=${PROXY_SERVER}`],
  });

  const page = await browser.newPage();
  await page.authenticate({
    username: PROXY_USERNAME,
    password: PROXY_PASSWORD,
  });

  await page.goto('https://httpbin.org/ip');
  const ip = await page.evaluate(() => JSON.parse(document.body.textContent).origin);
  console.log(`IP: ${ip}`);

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

  
Copy

Puppeteer Proxy Server Examples

Example 1 - Simple HTTP Proxy


const puppeteer = require('puppeteer');
const PROXY_SERVER = 'http://your-proxy-ip:port';

(async () => {
  let browser;
  try {
    browser = await puppeteer.launch({
      args: [`--proxy-server=${PROXY_SERVER}`],
    });

    const page = await browser.newPage();
    await page.goto('https://httpbin.org/ip');
    const ip = await page.evaluate(() => document.body.textContent);
    console.log('IP:', ip);
  } catch (error) {
    console.error('Error:', error);
  } finally {
    if (browser) await browser.close();
  }
})();

  
Copy

Example 2 - SOCKS5 Proxy Setup


const puppeteer = require('puppeteer');
const SOCKS_PROXY = 'socks5://127.0.0.1:1080';

(async () => {
  const browser = await puppeteer.launch({
    args: [`--proxy-server=${SOCKS_PROXY}`],
  });

  const page = await browser.newPage();
  await page.goto('https://httpbin.org/ip');
  const ip = await page.evaluate(() => document.body.textContent);
  console.log('IP:', ip);

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

  
Copy

Example 3 - Rotating Puppeteer Proxies

A common challenge when using authenticated proxies is that Chromium's launch arguments do not support the user:pass@host format directly in the --proxy-server flag. Attempting to do so will cause the credentials to be ignored.

To solve this, we use the proxy-chain library. It elegantly works around this limitation by creating a new, unauthenticated local proxy server. This local server acts as an intermediary, forwarding all requests from Puppeteer to your upstream proxy with the correct authentication credentials.

First, install the library in your project: npm i proxy-chain

The following example shows how to take a random authenticated proxy from a list and "anonymize" it for Puppeteer to use.


const puppeteer = require('puppeteer');
const proxyChain = require('proxy-chain');

(async () => {
  const proxyList = [
    'http://user1:[email protected]:8001',
    'http://user2:[email protected]:8002',
    'http://user3:[email protected]:8003',
  ];

  const oldProxyUrl = proxyList[Math.floor(Math.random() * proxyList.length)];
  const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl);

  const browser = await puppeteer.launch({
    args: [`--proxy-server=${newProxyUrl}`],
  });

  const page = await browser.newPage();
  await page.goto('https://httpbin.org/ip');
  const ip = await page.evaluate(() => document.body.textContent);
  console.log('IP:', ip);

  await browser.close();
  await proxyChain.closeAnonymizedProxy(newProxyUrl, true);
})();

  
Copy

Troubleshooting Common Puppeteer Proxy Issues

Proxy Connection Failures

Errors like ERR_PROXY_CONNECTION_FAILED often point to misconfigured proxy URLs, invalid credentials, or blocked ports. Test proxies using curl, ensure correct syntax in --proxy-server, and check for firewall or dependency issues on Linux systems.

Slow Proxy Performance

Free proxies are often overloaded. Reduce delays by using premium proxies, minimizing resource loading through page.setRequestInterception(true), and implementing caching for repeated assets.

Authentication Problems

If the script hangs or shows HTTP 407 errors, verify the username/password, and ensure page.authenticate() is correctly positioned before navigation. Some providers require custom formats for credentials.

Best Practices for Using Proxies with Puppeteer

puppeteer proxy best practices

To ensure your automation tasks are robust and remain undetected, follow these best practices:

Rotate IPs Aggressively

Use a large pool of high-quality rotating proxies. For large-scale scraping, changing the IP address for every single request (or every few requests) is the most effective strategy to avoid rate limits and IP bans.

Rotate User-Agents and Headers

Don't just rotate your IP. Rotate your User-Agent header for each request to mimic traffic from different browsers and devices. Modifying other headers to match common browser patterns further reduces the chances of being flagged as a bot.

Mimic Human Behavior

Modern anti-bot systems analyze behavior. Introduce randomized, slight delays between page interactions and requests. For advanced use cases, consider libraries like puppeteer-extra-plugin-stealth, which automatically patch Puppeteer to hide its tell-tale signs of automation (like navigator.webdriver).

Validate Proxies Before Use

Before starting a long-running task, send a quick test request through your proxy to an IP-checking website. This ensures the proxy is working and helps you avoid assigning a dead proxy to a critical job.

Monitor Performance and Failures

Keep logs of your proxies' performance. Track success rates, response times, and error types (e.g., 407, 503). Automatically discard or quarantine proxies that are slow or have a high failure rate.

Respect robots.txt

Even though proxies allow you to bypass certain blocks, you should still respect the target website's scraping policies outlined in their robots.txt file. This is crucial for ethical compliance and avoiding legal issues.

Alternatives to Puppeteer Proxies

Even though Puppeteer offers fine-grained control, alternative tools or services may better suit some use cases.

Alternative Automation Tools

  • Playwright supports multiple browsers and has built-in auto-waiting features.

  • Selenium supports various programming languages and enterprise-grade test setups.

Conclusion

Using proxies with Puppeteer is key for building secure, scalable, and resilient automation workflows. Whether you are scraping protected content, conducting UI tests across regions, or simply trying to avoid bans, configuring proxies is a fundamental skill.

From basic setup with --proxy-server to advanced techniques involving proxy rotation and performance monitoring, mastering Puppeteer proxies unlocks a new level of capability. By applying best practices and considering strategic alternatives when needed, developers can fully harness the power of Puppeteer for modern web automation.

joosep seitam

Joosep Seitam

Joosep Seitam is a serial entrepreneur based in Tallinn, Estonia, and the founder of Floxy. He also runs several other ventures, including Socialplug, Moropay, and Uproas. Joosep spends his time building AI-driven botnets, large-scale scraper systems, and advanced HTTP request frameworks powered by custom proxy networks. In his spare time, he writes about proxies, web scraping, and big data—sharing hard-earned insights from the frontlines of automation and digital infrastructure.

Subscribe to our newsletter

Oops! Something went wrong while submitting the form.

Share this article

More Floxy Blogs and Articles

Curious for more? Check out what else we’ve covered.

Effortless Data Extraction
at Any Scale

Extract the data you need—quickly and reliably.

Get Started