Proxy setup in Playwright

Proxies in Playwright with the username and password in the proxy option: Chromium, Firefox and WebKit, a proxy per context, and SOCKS5 limits.

Updated · Prokso editorial team

Connection details
Host
gw.prokso.com
Port
823 HTTP · 824 SOCKS5 — new IP per request · 10000–20000 sticky session, HTTP(S) and SOCKS5
Username and password
in your dashboard, on the plan page

Your dashboard generates ready-made lines in the format you need: choose the country, IP type and protocol.

Key takeaways
  • Host gw.prokso.com, ports 823 (HTTP), 824 (SOCKS5), 10000–20000 (sticky sessions, HTTP or SOCKS5)
  • The username and password are in your dashboard on the plan page
  • Check the IP in the response of the proxied request itself: the My IP page in a browser does not test your script
Proxies in Playwright: a short video guide · 0:35

A step-by-step guide to connecting Prokso proxies in Playwright. It takes a few minutes.

Step 1. Get the proxy details from your dashboard

Open your plan and copy the host gw.prokso.com, port, username and password. Port 823 is HTTP and 824 is SOCKS5 (both give a new IP for every request); ports 10000–20000 keep one IP (sticky session) for up to 120 minutes and work as both HTTP and SOCKS5 (each port is a separate address). Set the country in the username: username__cr.ua.

The “Access” block on the plan page: host, ports, username and password for the proxy line
The “Access” block on the plan page: host, ports, username and password for the proxy line

Step 2. Set the proxy in the launch options

Playwright takes the proxy together with the username and password in the proxy option — no separate authentication needed. Works for Chromium, Firefox and WebKit.

Step 3. Run the example

The code below opens a page and prints the proxy IP. In Python the syntax is the same: chromium.launch(proxy={...}).

import { chromium } from "playwright";

const browser = await chromium.launch({
  proxy: { server: "http://gw.prokso.com:823", username: "USERNAME", password: "PASSWORD" },
});
const page = await browser.newPage();
await page.goto("https://api.ipify.org");
console.log(await page.textContent("body"));
await browser.close();

Save it as check.mjs and run node check.mjs.

Step 4. Different IPs for different contexts

You can also set a proxy per context: browser.newContext({ proxy }). That way one browser runs several profiles on different sticky ports.

Step 5. Check the IP in the launched browser

The example in step 3 opens https://api.ipify.org in the Playwright browser and prints the IP the website sees — it should differ from yours. With several contexts, open that address in each one: different sticky ports give different IPs. Your regular browser doesn't use this proxy and will show your own address.

Example run: the output shows the proxy IP, not yours. On port 823 every run gets a new address
Example run: the output shows the proxy IP, not yours. On port 823 every run gets a new address

A proxy per context: several IPs in one browser

A context in Playwright is an isolated profile with its own cookies. By giving each context its own sticky port, you get several independent sessions in one browser:

const browser = await chromium.launch();

for (const port of [10001, 10002]) {
  // each context has its own cookies and its own sticky IP
  const context = await browser.newContext({
    proxy: { server: `http://gw.prokso.com:${port}`, username: "USERNAME", password: "PASSWORD" },
  });
  const page = await context.newPage();
  await page.goto("https://prokso.com/ip");
  console.log(port, await page.textContent("body"));
  await context.close();
}
await browser.close();

This saves memory compared with a separate browser for each session.

How to cut traffic use

Cancel the loading of heavy resources through route. Images, video, and fonts make up most of a page's volume and are not needed for data collection:

await page.route("**/*", (route) => {
  // skip heavy resources: they are not needed for data collection
  const skip = ["image", "media", "font"].includes(route.request().resourceType());
  return skip ? route.abort() : route.continue();
});

If the page does not open

  • net::ERR_PROXY_CONNECTION_FAILED. The browser could not reach the proxy: check the server field.
  • net::ERR_TUNNEL_CONNECTION_FAILED. The proxy refused the connection: check the username, the password, and the remaining traffic.
  • Navigation timeout. The default 30 seconds can be too short for residential addresses. Increase the timeout in page.goto().
  • SOCKS5 with a password in Chromium. It is not supported. Use HTTP or access by IP.

More about the codes is on the proxy error codes page.

FAQ

Does the proxy work the same in Chromium, Firefox, and WebKit?

An HTTP proxy with a username and password works in all three. The differences concern SOCKS5: with a password, it is not supported in Chromium.

How do I set a proxy in Playwright Test tests?

In the configuration file, in the <code>use</code> section, specify the same <code>proxy</code> object with the <code>server</code>, <code>username</code>, and <code>password</code> fields.

Can I send some addresses past the proxy?

Yes, the <code>proxy</code> object has a <code>bypass</code> field that takes a comma-separated list of domains.