NodeLighthouse

Residential proxies with Playwright

Playwright takes a proxy object with server, username and password, either when you launch the browser or when you create a context. A sticky session per context gives each context its own stable residential IP.

Your username and password are on the Proxy generator page after you sign in. Host gw.nodelighthouse.com: port 9000 rotating, 10000 sticky, 11000 SOCKS5.

Get your credentials

Your username and password are on the Proxy generator page of the dashboard. Use the password exactly as shown there; country, state, city and session options all go in the username.

For browsers, prefer the sticky port 10000. A single page load fetches many scripts, images and API calls; on the rotating port 9000 those can each leave from a different IP, which many sites treat as inconsistent.

npm i playwright
npx playwright install chromium

Set the proxy at launch

Every page in this browser uses the same proxy. The server field holds only the scheme, host and port; credentials go in username and password.

const { chromium } = require("playwright");

(async () => {
  const browser = await chromium.launch({
    proxy: {
      server: "http://gw.nodelighthouse.com:10000",
      username: "<USERNAME>-type-residential-country-us-lifetime-10-session-abc12345",
      password: "<PASSWORD>",
    },
  });
  const page = await browser.newPage();
  await page.goto("https://api.ipify.org");
  console.log(await page.textContent("body"));
  await browser.close();
})();

Give each context its own IP

Pass proxy to browser.newContext() to run several isolated sessions in one browser. Give each context a different session id so each one keeps its own IP.

const { chromium } = require("playwright");
const crypto = require("crypto");

function stickyUser() {
  const sessionId = crypto.randomBytes(4).toString("hex"); // 8 chars, a-f0-9
  return "<USERNAME>-type-residential-country-us-lifetime-10-session-" + sessionId;
}

(async () => {
  const browser = await chromium.launch();
  for (let i = 0; i < 3; i++) {
    const context = await browser.newContext({
      proxy: {
        server: "http://gw.nodelighthouse.com:10000",
        username: stickyUser(),
        password: "<PASSWORD>",
      },
    });
    const page = await context.newPage();
    await page.goto("https://api.ipify.org");
    console.log("context", i, await page.textContent("body"));
    await context.close();
  }
  await browser.close();
})();

Python version

The Python API takes the same fields as a dict. This example targets Los Angeles on the rotating port.

# pip install playwright && playwright install chromium
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(proxy={
        "server": "http://gw.nodelighthouse.com:9000",
        "username": "<USERNAME>-type-residential-country-us-state-california-city-losangeles",
        "password": "<PASSWORD>",
    })
    page = browser.new_page()
    page.goto("https://api.ipify.org")
    print(page.text_content("body"))
    browser.close()

Questions

Can I use the SOCKS5 port with Playwright?
Use the HTTP ports with Playwright. Chromium does not support username and password authentication on SOCKS5 proxies, and the HTTP ports already carry HTTPS traffic through a tunnel.
How long does a sticky session last?
As long as the lifetime in the username, in minutes, from 1 to 1440. Residential devices can go offline, so a session can occasionally change IP before its lifetime ends. Plan for that in long jobs.
Should I use Playwright or a plain HTTP client?
Use an HTTP client such as Python requests when the data is in the HTML or a JSON endpoint; it uses far less bandwidth. Use Playwright when the page needs JavaScript to render. Bandwidth is billed at $1.65/GB, and browsers download much more per page.

Related guides: Puppeteer · Selenium

Try it on your own targets

A flat $1.65/GB on every plan, with state and city targeting included. Start with the $2 for 500 MB test pack, paid in crypto.

Residential proxies with Playwright: setup guide