Setup guide

Playwright proxy setup for Python and Node

Playwright takes the proxy when the browser launches, with the username and password in fields of their own. The option names are the same in Python and Node, so both versions are here.

Before you start

  • Playwright for Python (pip install playwright) or for Node (npm i playwright).
  • A browser downloaded with playwright install chromium.
  • Your service’s HOST, PORT, USERNAME and PASSWORD.

Your connection details

Sign in to the dashboard and open the service you bought. Its page shows the host, port, username and password for that service. There is no single ProxyPanda address to remember, so copy them from there each time. The code in these guides uses the placeholders below; replace each one with your own value.

HOST
The proxy address for this service, exactly as the service page shows it.
PORT
The port to connect to. Copy it with the host, since it can differ from one service to the next.
USERNAME
Your proxy login. It is separate from the email you use for the dashboard.
PASSWORD
Copy it in full. On residential, the options you choose in the dashboard are added to the end of the password, so a password typed from memory loses them.
You can skip the username and password by adding the IP address you connect from to the service’s allowlist. Then only HOST and PORT go into your code.

Need help? Letting the proxy recognise your IP address

The examples use HTTP, which reaches https sites through an encrypted tunnel. SOCKS5 works too: residential ports accept both, and ISP and datacenter proxies switch protocol in the dashboard.

Steps

  1. Pass proxy to launch() in Pythonserver holds the scheme, host and port only. username and password sit in their own keys, and Playwright answers the proxy’s login challenge with them.
    check_ip.pypython
    from playwright.sync_api import sync_playwright
    
    with sync_playwright() as p:
        browser = p.chromium.launch(
            proxy={"server": "http://HOST:PORT", "username": "USERNAME", "password": "PASSWORD"}
        )
        page = browser.new_page()
        page.goto("https://api.ipify.org?format=json")
        print(page.inner_text("body"))
        browser.close()
  2. The same launch in NodeThe Node API uses identical option names. Save the file with an .mjs extension so top-level await works, and run it with node.
    check-ip.mjsjavascript
    import { chromium } from 'playwright';
    
    const browser = await chromium.launch({
      proxy: { server: 'http://HOST:PORT', username: 'USERNAME', password: 'PASSWORD' },
    });
    const page = await browser.newPage();
    await page.goto('https://api.ipify.org?format=json');
    console.log(await page.textContent('body'));
    await browser.close();
  3. Give each context its own proxyA proxy can also be set per context, with new_context(proxy=...) in Python or newContext({ proxy }) in Node. One browser can then run several profiles, each through its own credentials.
    contexts.pypython
    context = browser.new_context(
        proxy={"server": "http://HOST:PORT", "username": "USERNAME", "password": "PASSWORD"}
    )
    page = context.new_page()
  4. Block images, media and fontsA page pulls in far more than its HTML. On residential every byte counts toward the bill, so abort the resource types your script never looks at.
    block_media.pypython
    page.route(
        "**/*",
        lambda route: route.abort()
        if route.request.resource_type in ("image", "media", "font")
        else route.continue_(),
    )

Rotating and sticky IPs

A browser opens several connections to load one page. With Randomize IP on residential, each new connection can leave from a different address, so a site may see one visit arrive from several places. If a task needs one address throughout, choose Sticky IP.

ISP and datacenter IPs keep one address for the whole term, which suits a logged-in context you come back to day after day.

Common errors and fixes

Page.goto: Timeout exceeded, with no 407 in sight

With a wrong username or password, Chromium keeps retrying the proxy login and the navigation times out instead of reporting a 407. Check the credentials before you raise the timeout.

net::ERR_PROXY_CONNECTION_FAILED

Nothing answered at HOST:PORT. Compare both with the service page and check that the service is still active.

net::ERR_TUNNEL_CONNECTION_FAILED

The proxy was reached but could not open a tunnel to the site. Retry once. If it keeps happening for one site only, bring the URL to Discord.

Need help? What a 407 or 403 message means

Which line to pick

Browser automation moves a lot more data than plain HTTP calls, so datacenter IPs keep it cheap. Choose residential with Sticky IP when a test needs a home-network address, or ISP when the same profile logs in every day.

Not sure what a word means? The glossary explains it in plain English.

Stuck on a step?

Paste the command and the error into Discord, with your password taken out. People there have met most of these errors before.

Join the Discorddiscord.gg/eanHcCQT7n
Start with $5Ask in Discord