Proxy exits in 64 countries and 172 cities, sold per GB, IP, day or request.

Code and command line

Puppeteer proxy setup

Puppeteer drives Chrome through the DevTools protocol, and Chrome reads its proxy from a command-line switch. The switch only carries the host and port. The login and password are answered separately, page by page, with page.authenticate.

Because the proxy belongs to the whole browser process, the clean pattern is one browser per login. The steps below show that pattern, a helper that hides the details, and how to rotate or hold an address between runs.

What do you need before adding a proxy in Puppeteer?

Tick these off before the first step. Your login and password appear in your account once the first top-up of $40 or more has been credited.

Requirements for Puppeteer
RequirementDetail
Node.js 18 or newerCurrent Puppeteer releases require a supported Node.js version.
puppeteernpm i puppeteer downloads a matching Chrome build.
TopProxy login and passwordFor example tp7k2m9_country-us.
Async codeEvery call returns a promise, so use an async function or top-level await in an ES module.

Where do the proxy host, port and login go in Puppeteer?

Work through the steps in order. Swap YOUR_PASSWORD for your proxy password and tp7k2m9 for your account name.

  1. Launch Chrome with the gateway

    Add --proxy-server to the launch arguments with the scheme, host and port. Do not put the login in this value: Chrome ignores credentials inside the switch.

    import puppeteer from 'puppeteer';
    
    const browser = await puppeteer.launch({
      args: ['--proxy-server=http://proxy.topproxy.shop:8080'],
    });
  2. Answer the login challenge on each page

    Call page.authenticate right after creating a page and before the first navigation. Puppeteer then replies to the proxy challenge for every request that page makes.

    const page = await browser.newPage();
    await page.authenticate({
      username: 'tp7k2m9_country-us',
      password: process.env.TOPPROXY_PASSWORD ?? 'YOUR_PASSWORD',
    });
    await page.goto('https://ipinfo.io/json', { waitUntil: 'domcontentloaded' });
    console.log(await page.evaluate(() => document.body.innerText));
    await browser.close();

    Tip.Popups and pages opened by links are new pages. Call authenticate on them too, or listen for the targetcreated event and do it there.

  3. Wrap it in a helper

    A small function that takes a country, city and session keeps the login format out of your scraping code and makes sure every browser closes.

    import puppeteer from 'puppeteer';
    
    export async function withProxy({ country = 'us', city, session, life = 30 }, job) {
      let username = 'tp7k2m9_country-' + country;
      if (city) username += '_city-' + city;
      if (session) username += '_session-' + session + '_life-' + life;
      const browser = await puppeteer.launch({ args: ['--proxy-server=http://proxy.topproxy.shop:8080'] });
      try {
        const page = await browser.newPage();
        await page.authenticate({ username, password: process.env.TOPPROXY_PASSWORD });
        return await job(page);
      } finally {
        await browser.close();
      }
    }
  4. Cut traffic with request interception

    Metered products are billed per GB. Interception lets you drop images and media before they are fetched. Turn it on after authenticate so the two features work together.

    await page.setRequestInterception(true);
    page.on('request', (req) => {
      if (['image', 'media', 'font'].includes(req.resourceType())) req.abort();
      else req.continue();
    });

How can you confirm the proxy is active in Puppeteer?

Load ipinfo.io in a page that went through the helper. The returned address should differ from your own, and the country should match the login.

const info = await withProxy({ country: 'us' }, async (page) => {
  await page.goto('https://ipinfo.io/json');
  return JSON.parse(await page.evaluate(() => document.body.innerText));
});
console.log(info.ip, info.country);

The response shown here is shortened to the fields that matter. The region and time zone follow the exit, in this case Canada.

GET https://ipinfo.io/json
{
  "ip": "198.51.100.47",
  "city": "Toronto",
  "region": "Ontario",
  "country": "CA",
  "timezone": "America/Toronto"
}

198.51.100.47 is an address reserved for documentation. A live check prints a real exit.

How do you switch between rotating and held IPs in Puppeteer?

Each new browser on a rotating login starts on a new exit. Inside one browser, Chrome reuses connections, so pages may share an address for a while. To guarantee one address through a multi-step flow, pass a session name. To guarantee a new one, start a new browser or use a new session name.

await withProxy({ country: 'us' }, job);

How the login is put together

Every setting lives in the login, joined with underscores. Nothing else in Puppeteer changes when you switch location or session.

Parts of a TopProxy login
PartMeaningRule
tp7k2m9Your account nameAlways first. Yours is shown in your account and replaces tp7k2m9 in every example here.
_country-usExit countryTwo-letter code in lowercase. 64 countries to choose from.
_city-new-yorkExit city, optionalLowercase, spaces become hyphens. 172 cities in total.
_session-a1b2c3Session name, optionalLetters and digits you pick. Same name, same exit. New name, new exit.
_life-30Session life in minutesOnly with a session. Residential 1 to 120 minutes, mobile 1 to 60 minutes, long session ISP up to 12 hours (life 720).

All parts togethertp7k2m9_country-us_city-new-york_session-a1b2c3_life-30

How do you choose an exit country or city in Puppeteer?

Pass the country code and, optionally, a city value. The helper turns it into tp7k2m9_country-es_city-barcelona.

await withProxy({ country: 'es' }, job);

Codes and city values for all 64 countries are listed on the proxy locations pages.

How do you fix proxy connection errors in Puppeteer?

Find the line that matches what you see. Most problems come down to the login, the port or the network you are on.

Puppeteer symptoms, causes and fixes
SymptomLikely causeFix
net::ERR_INVALID_AUTH_CREDENTIALSThe page navigated before authenticate finished, or the password is wrong.Await page.authenticate before page.goto and check the password.
net::ERR_PROXY_CONNECTION_FAILEDChrome cannot reach the gateway: wrong host, wrong port or a blocked network.Use http://proxy.topproxy.shop:8080 exactly and test the network with cURL.
Auth works on the first page but not in popupsNew tabs are separate pages without credentials.Authenticate new pages from the targetcreated event.
Login appears inside --proxy-server and failsChrome does not read credentials from the switch.Leave only scheme, host and port in the switch and use authenticate.

Still stuck? Run the same login through the cURL check. If cURL connects, the issue is in the Puppeteer settings. If it does not, write to support with the error text.

What kind of proxy pairs well with Puppeteer?

All products sit behind the same gateway and share one prepaid balance, so moving from one to another means buying the other product and changing the login, nothing more.

Calling pages from code at scale? The TopProxy API docs cover the Scraping API, which renders pages and retries on its own.

What else do Puppeteer users ask about proxies?

Can two pages in one Puppeteer browser use different countries?

Not reliably. The proxy server is set for the whole Chrome process, and the login is checked per connection, so pages sharing connections can end up on the same exit. Start one browser per location instead.

Does page.authenticate work in headless mode?

Yes. It answers the proxy challenge through the DevTools protocol, which is the same in headless and headed Chrome.

Why not use the SOCKS5 port with Puppeteer?

Chrome supports SOCKS5 only without a username and password. TopProxy logins need both, so the HTTP port 8080 is the one that works.

Is there a package that handles this for me?

Some community packages run a local proxy that adds the login for you. They are not needed with TopProxy, since --proxy-server and page.authenticate already cover every case.

How do I reduce GB usage with Puppeteer?

Block images, fonts and media with request interception, wait for domcontentloaded instead of networkidle, and reuse one page for several URLs on the same site.

Ready to connect Puppeteer?

Open an account, add $40 or more in crypto, and your login and password are waiting in the account area.