Puppeteer integration

Proxies for Puppeteer

Puppeteer drives Chrome from Node.js. Point it at gate.proxyhat.com, log in with page.authenticate, and every page exits through a residential or mobile IP in the country you choose: a fresh IP per connection, or one sticky IP per worker.

Residential proxies
Code tested on our gateway HTTP with username and password Traffic never expires

What teams run Puppeteer through proxies for

Public data collection

Load public pages, such as prices, listings and search results, the way a visitor in that country sees them.

Localization and ad checks

Check that geo-targeted pages, translations and ads render correctly in each market, from a residential or mobile connection there.

Testing from outside your network

Run end-to-end tests of your own site as an outside visitor: geo-redirects, CDN rules, consent banners and checkout by country.

Connection details

Hostgate.proxyhat.com
SOCKS5 port1080
HTTP port8080
AuthenticationUsername and password from the Proxies page of your dashboard
Username for one browserUSERNAME-country-US-sid-a3f8c20d1e-ttl-30m

Everything after your username is a flag: -country-US picks the exit country, -type-mobile the mobile carrier pool, -sid-… keeps one IP and -ttl-30m sets for how long (up to 24 hours). Leave out -type-mobile for residential IPs.

Puppeteer proxy code

Replace USERNAME and PASSWORD with the proxy credentials from the Proxies page of your dashboard. Save as an .mjs file and run it with Node.js after npm install puppeteer.

import puppeteer from 'puppeteer';

// Chromium takes the proxy address as a launch flag...
const browser = await puppeteer.launch({
  args: ['--proxy-server=http://gate.proxyhat.com:8080'],
});
const page = await browser.newPage();

// ...and the credentials per page. No -sid-: every new connection can exit from a new IP.
await page.authenticate({
  username: 'USERNAME-country-US',
  password: 'PASSWORD',
});

await page.goto('https://httpbin.org/ip');
console.log(await page.$eval('body', (el) => el.innerText));
await browser.close();

--proxy-server sets only the address: Chromium ignores a user:pass part in that flag, so page.authenticate answers the gateway’s login challenge. Without -sid- in the username, every new connection can get a new IP.

Tested on November 28, 2026 against gate.proxyhat.com with Puppeteer 25.19 and Chrome 158: the rotating sample printed a US IP, the sticky sample three different US IPs.

Checked against: Puppeteer: Page.authenticate, Puppeteer: Browser.createBrowserContext · checked November 28, 2026

Rotating, sticky or no rotation

The session type is part of the username. Your code stays the same; only the login string changes.

Rotating

No session ID: each new connection can exit from a different IP. Good for many independent page loads.

USERNAME-country-US

Sticky

Add -sid- with 10 random hex characters and a -ttl-: the IP holds for that long (10m, 30m, 1h, up to 24h). Use it for multi-page flows that should stay on one address.

USERNAME-country-US-sid-a3f8c20d1e-ttl-30m

No rotation

Add -sid- with -norotate-true and no -ttl-: the IP doesn’t rotate on a timer and stays until you switch to a new sid.

USERNAME-country-US-sid-a3f8c20d1e-norotate-true

One sid holds one exit IP and handles about 4–5 connections at a time, so give every worker or browser its own sid. Sticky sessions last up to 24 hours. Add -type-mobile for 4G/5G carrier IPs; leave it out for residential.

Proxy errors and what they mean

407 Proxy Authentication RequiredThe gateway didn’t accept the login: the username or password is wrong, or the username format is (a typo in a flag such as -country-US). Copy both from the Proxies page of your dashboard and make sure the auth step runs before the first page load.
402 Payment RequiredThe traffic balance is used up, or the sub-user has reached its traffic limit. Top up or raise the limit in the dashboard; traffic you buy never expires.
ERR_TUNNEL_CONNECTION_FAILEDChrome’s name for a proxy that refused the connection, and it can hide a 402 or another gateway status. Send the same username and password through curl -x http://gate.proxyhat.com:8080 to see the real code.
ERR_PROXY_CONNECTION_FAILEDChrome couldn’t reach the gateway at all. Check the host and port (gate.proxyhat.com, 8080 for HTTP) and that your network allows outgoing connections to it.

All gateway errors and username flags are in the documentation: ProxyHat docs →

Price

Mobile and residential traffic share one price and one balance: from $4.00/GB for a 1 GB pack down to $1.80/GB for 1,000 GB. Traffic never expires, and all your browsers draw from the same balance. See pricing →

Puppeteer proxy setup: FAQ

Can Puppeteer use a SOCKS5 proxy with a username and password?

No. Chromium supports SOCKS5 proxies only without authentication, so a SOCKS5 proxy with a password won’t log in. Use HTTP on port 8080 with page.authenticate, as in the samples; it carries HTTPS sites too.

Why not put the username and password in --proxy-server?

Chromium ignores credentials in that flag. The flag sets the address; the login is sent when the gateway asks for it (HTTP 407), which is what page.authenticate does.

How do I give each worker its own IP?

Give each worker its own sid in the username and its own browser context (browser.createBrowserContext()), as in the sticky sample. One sid handles about 4–5 parallel connections, so don’t share it between workers.

How long does a sticky IP last?

As long as the -ttl- flag says, up to 24 hours: -ttl-30m, -ttl-1h, -ttl-24h. For an IP that doesn’t rotate on a timer, use -sid- with -norotate-true and no -ttl-.

How do I pick a country or use mobile IPs?

Add -country- with a two-letter code (residential IPs in 195+ countries) and -type-mobile for 4G/5G carrier IPs (150+ countries). Mobile and residential cost the same and draw from one balance.

The page shows HTTP ERROR 407. What’s wrong?

The gateway didn’t accept the login. Check that page.authenticate runs before page.goto and that the username and password are copied exactly from your dashboard. The errors table above lists the other codes.

Does the same setup work with Playwright?

Playwright takes the server, username and password in its proxy launch option, so it needs no separate authenticate step. Our Playwright guide, linked below, walks through rotating proxies there.

Run Puppeteer through residential IPs

Create an account, buy a small pack and run the samples above before you scale out.

Pay as you go · Traffic never expires · Crypto checkout