Puppeteer proxy authentication works reliably when you separate the proxy address from its credentials and answer the HTTP authentication challenge before navigation. This guide shows the working page.authenticate() pattern, explains why authenticated SOCKS5 proxies are different in Chrome, and gives you a repeatable way to rotate and verify the exit IP between browser runs.
What you need
You need a Node.js project with Puppeteer installed, an HTTP or SOCKS5 proxy host and port, and the credentials supplied by your proxy service. Keep the credentials in environment variables or a secret manager. Do not commit them to source control or print the complete proxy URL in logs.
For a mobile-proxy setup, the proxy endpoint should already be attached to a 4G/LTE dongle and its SIM. ProxyKite provides HTTP and SOCKS5 access for your own dongles, with cloud routing so the machine running Puppeteer does not need a static public IP or port forwarding. Its authentication guide explains the available username/password and IP-allowlist approaches.
If the host, port, username and password are unfamiliar, first read proxy format explained. Those four fields are enough for the examples below.
Create a small project if you need a clean test:
mkdir puppeteer-proxy-test
cd puppeteer-proxy-test
npm init -y
npm install puppeteer
Set values for one proxy. Use the actual host and port from your proxy dashboard; the placeholders below are deliberately not real credentials.
export PROXY_HOST="proxy.example.com"
export PROXY_PORT="8080"
export PROXY_USER="proxy-user"
export PROXY_PASSWORD="replace-this-secret"
Step 1: Put the proxy in --proxy-server
Why: Chrome needs the proxy route at browser launch, but it does not use credentials embedded in the launch setting.
Pass only the scheme, host and port to Puppeteer. For an HTTP proxy, http:// is explicit and easy to recognise when troubleshooting.
import puppeteer from 'puppeteer';
const proxyServer = `http://${process.env.PROXY_HOST}:${process.env.PROXY_PORT}`;
const browser = await puppeteer.launch({
headless: true,
args: [`--proxy-server=${proxyServer}`],
});
Do not turn that into this:
args: ['--proxy-server=http://proxy-user:replace-this-secret@proxy.example.com:8080']
Chrome’s manual proxy settings do not use credentials embedded in the proxy setting. The browser’s proxy documentation says proxy authentication follows the ordinary credential flow instead. Puppeteer therefore needs page.authenticate() after the page exists.
Success at this stage means Chromium launches without a proxy syntax error. It does not yet prove that the proxy credentials work; that happens after authentication and navigation.
Step 2: Authenticate an HTTP proxy with page.authenticate()
Why: page.authenticate() supplies credentials when the page receives an HTTP authentication challenge, including the challenge from an HTTP proxy.
Create the page, authenticate it, and only then navigate. The order matters.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({
headless: true,
args: [
`--proxy-server=http://${process.env.PROXY_HOST}:${process.env.PROXY_PORT}`,
],
});
try {
const page = await browser.newPage();
await page.authenticate({
username: process.env.PROXY_USER,
password: process.env.PROXY_PASSWORD,
});
const response = await page.goto('https://example.com', {
waitUntil: 'domcontentloaded',
timeout: 30_000,
});
if (!response) {
throw new Error('Navigation returned no response');
}
console.log('status:', response.status());
console.log('title:', await page.title());
} finally {
await browser.close();
}
Puppeteer’s page.authenticate() reference documents it as the method for HTTP authentication and notes that it enables request interception behind the scenes. That can affect performance, so use it where you need authenticated HTTP access and avoid enabling extra interception handlers unless your application needs them.
Success looks like a normal HTTP response and page title. A proxy credential failure usually appears as an authentication error, a proxy connection error, or a page that never gets past the proxy challenge. Check the host, port, username and password separately before changing the browser flags.
If your application opens several pages, authenticate each page before its first navigation. A simple rule is to wrap page creation so an unauthenticated page cannot accidentally make a request:
async function newAuthenticatedPage(browser) {
const page = await browser.newPage();
await page.authenticate({
username: process.env.PROXY_USER,
password: process.env.PROXY_PASSWORD,
});
return page;
}
Step 3: Handle SOCKS5 authentication correctly
Why: SOCKS5 credentials are negotiated in the SOCKS protocol, but Chrome’s SOCKS5 proxy implementation does not support proxy authentication methods.
This is the common trap. Changing the scheme from http:// to socks5:// does not make the HTTP authentication call work:
const browser = await puppeteer.launch({
headless: true,
args: ['--proxy-server=socks5://proxy.example.com:1080'],
});
const page = await browser.newPage();
await page.authenticate({
username: process.env.PROXY_USER,
password: process.env.PROXY_PASSWORD,
});
page.authenticate() is for HTTP authentication, not a SOCKS5 username/password handshake. Chromium’s current network-stack documentation explicitly says that no authentication methods are supported for SOCKS5 in Chrome. The result can be ERR_SOCKS_CONNECTION_FAILED even when the credentials are correct for another client.
You have three practical choices:
- Use the proxy’s HTTP endpoint and the
page.authenticate()pattern in Step 2. This is the simplest option for Puppeteer. - Use a SOCKS5 endpoint protected by IP allowlisting, if your proxy service supports it. Chrome then connects without a SOCKS5 password, while the service restricts access to the allowlisted machine.
- Put a local adapter between Chrome and the upstream authenticated SOCKS5 service. The adapter handles the upstream SOCKS5 credentials and exposes a loopback endpoint that Chrome can use without SOCKS5 credentials. Bind that local listener to
127.0.0.1, restrict its access, and treat it as a separate process to monitor.
For a ProxyKite endpoint, HTTP is usually the cleanest Puppeteer choice because the service also supports HTTP access and either username/password or IP-whitelist authentication. If your application specifically needs SOCKS5, configure the compatible authentication mode before testing the browser.
For an unauthenticated SOCKS5 endpoint, Chrome’s launch setting is simply:
args: [
'--proxy-server=socks5://127.0.0.1:1080',
'--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1',
]
The resolver rule is useful when you want hostname resolution to happen through SOCKS5 rather than through the local network. Test it with an endpoint you control, because Chrome has other components that can issue DNS requests outside ordinary URL loading.
Step 4: Use one browser per proxy
Why: --proxy-server is a browser launch setting, not a page-level setting, so separate browser processes make proxy assignment and session boundaries predictable.
Use a function that launches, authenticates, does the work, and closes one browser. Do not try to change --proxy-server after launch or assume that creating a second page changes the browser’s route.
import puppeteer from 'puppeteer';
async function runThroughHttpProxy(url) {
const browser = await puppeteer.launch({
headless: true,
args: [
`--proxy-server=http://${process.env.PROXY_HOST}:${process.env.PROXY_PORT}`,
],
});
try {
const page = await browser.newPage();
await page.authenticate({
username: process.env.PROXY_USER,
password: process.env.PROXY_PASSWORD,
});
await page.goto(url, { waitUntil: 'networkidle2', timeout: 30_000 });
return await page.title();
} finally {
await browser.close();
}
}
console.log(await runThroughHttpProxy('https://example.com'));
For concurrent work, launch one browser per proxy assignment and keep each browser’s cookies, local storage and credentials separate. This makes it easier to tell whether a failure belongs to the target page, the proxy route or the browser session. It also prevents a later task from inheriting state that an earlier task left behind.
Step 5: Rotate the mobile IP between runs
Why: rotating between complete browser runs gives the next run a fresh route while keeping each run’s proxy and session state easy to audit.
A rotation link is an action, not a new proxy host. Call the link assigned to the dongle, wait until the route is ready, then create a new browser. Read ProxyKite’s rotation-link documentation and rotation API reference for the exact link or API operation available to your account.
The following pattern keeps the link in an environment variable and does not invent an endpoint path:
async function rotateMobileIp() {
const response = await fetch(process.env.ROTATION_URL);
if (!response.ok) {
throw new Error(`Rotation request failed: ${response.status}`);
}
}
Use it between two calls to runThroughHttpProxy():
const firstIp = await readExitIp();
await rotateMobileIp();
let secondIp;
for (let attempt = 0; attempt < 10; attempt += 1) {
secondIp = await readExitIp();
if (secondIp !== firstIp) break;
await new Promise(resolve => setTimeout(resolve, 1_000));
}
console.log({ firstIp, secondIp });
Do not reuse the same browser if your goal is a clean run. Close it, invoke the rotation action, verify the new route, and launch again. If the IP has not changed after the polling window, record that result and investigate the rotation response rather than silently assuming the route changed.
Step 6: Verify the exit IP
Why: a page loading successfully proves that navigation worked; it does not prove that traffic left through the intended mobile route.
Check the public IP through the same authenticated page. Replace the example IP service with an endpoint you operate if the data is sensitive or if you need a durable audit trail.
async function readExitIp() {
const browser = await puppeteer.launch({
headless: true,
args: [
`--proxy-server=http://${process.env.PROXY_HOST}:${process.env.PROXY_PORT}`,
],
});
try {
const page = await browser.newPage();
await page.authenticate({
username: process.env.PROXY_USER,
password: process.env.PROXY_PASSWORD,
});
const response = await page.goto('https://api.ipify.org?format=json', {
waitUntil: 'domcontentloaded',
timeout: 30_000,
});
if (!response) throw new Error('IP check returned no response');
const body = await response.json();
if (!body.ip) throw new Error('IP check did not return an address');
return body.ip;
} finally {
await browser.close();
}
}
Run the check at least once before rotation and once after it. Log the selected proxy identifier, response status, timestamp and observed exit IP, but redact the username and password. For a broader check, compare the result with the IP shown by the dongle’s carrier connection and confirm that the request is not bypassing the proxy because of a bypass list or a second proxy configuration.
The guide how 4G IP rotation works covers the network side of this process. Puppeteer only controls the browser route; the carrier and dongle determine whether a rotation action produces a different public address.
Troubleshooting Puppeteer proxy authentication
ERR_NO_SUPPORTED_PROXIES or immediate launch failure
Check the scheme and formatting first. Use http://host:port for an HTTP proxy and socks5://host:port for an unauthenticated SOCKS5 route. Do not include user:password@ in --proxy-server.
The page asks for credentials or returns a 407 response
Confirm that page.authenticate() runs before page.goto(), that the credentials are strings, and that the page is using the same browser launched with the proxy flag. A 407 is an HTTP proxy authentication response, so verify the HTTP endpoint rather than switching to SOCKS5 as a guess.
HTTP works but SOCKS5 fails
That difference is expected when the SOCKS5 service requires credentials. Test the SOCKS5 host and port with a client that supports SOCKS5 authentication, or choose the HTTP endpoint for Puppeteer. Chrome’s SOCKS5 path does not accept the username/password supplied to page.authenticate().
The check shows the local IP
Inspect the effective launch arguments, remove an unintended --proxy-bypass-list, and ensure the page was not created in a different browser. Also check the IP-check URL outside Puppeteer so you know the service is returning the address you expect.
Rotation returns success but the IP is unchanged
Treat the rotation response and the observed exit IP as separate checks. Confirm that the rotation link belongs to the right dongle, poll for the new result, and make sure an existing browser was closed before the next run. If the route remains the same, retain the old IP in your logs and follow the account’s rotation documentation instead of guessing at a delay.
FAQ
Can Puppeteer use a proxy username and password?
Yes, for an HTTP proxy, launch Chrome with the proxy host and port and then call page.authenticate({ username, password }) before navigation. Credentials embedded in --proxy-server are not the reliable configuration path for Chrome.
Does page.authenticate() work with a SOCKS5 proxy?
No. Puppeteer’s method is for HTTP authentication, while Chrome does not support SOCKS5 proxy authentication methods in its network stack. Use an HTTP endpoint, IP allowlisting, or a local adapter that handles the upstream SOCKS5 login.
Should I launch a new browser for every proxy?
Yes, when the proxy is selected with --proxy-server. The setting applies to the browser process, so one browser per proxy keeps routing, cookies and authentication state clear.
How do I rotate a proxy IP in Puppeteer?
Call the rotation link or API for the assigned mobile route, close the current browser, then launch a new browser through the same proxy endpoint. Verify the public exit IP before starting the next workload; see the ProxyKite rotation API for the account-specific operation.
What is the simplest authenticated setup for a 4G proxy farm?
Use an HTTP endpoint with --proxy-server and page.authenticate(), and keep one browser process per dongle or proxy assignment. ProxyKite’s per-dongle licence is $9 per dongle per month, with traffic using your own SIM data plan and no per-GB charge; contact ProxyKite if you need help planning a larger fleet.