PRIVATEBYTE
ServersProxiesAgentsStatusNetworkAboutFree Proxies
Sign inDeploy

← Docs / Proxies

Datacenter proxies with Playwright

Playwright takes the proxy as a launch option. This page uses Python and the datacenter tier: a US datacenter IP that changes for every new connection.

What you need

  • Your proxy API key, from the Proxies page in the portal.
  • pip install playwright, then playwright install chromium.
export PB_PROXY_KEY="YOUR_KEY"

Launch a browser through the proxy

import os
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        proxy={
            "server": "http://proxy.privatebyte.com:3128",
            "username": os.environ["PB_PROXY_KEY"],
            "password": "datacenter",
        }
    )
    page = browser.new_page()
    page.goto("https://api.ipify.org")
    print(page.inner_text("body"))  # a US datacenter address
    browser.close()

Playwright sends the credentials for you, so there is no extra authentication step.

Get a new IP

A browser keeps its connections open. Every page in the same context leaves from the same address. Open a new context to get a new one:

for _ in range(3):
    context = browser.new_context()
    page = context.new_page()
    page.goto("https://api.ipify.org")
    print(page.inner_text("body"))
    context.close()

One page, several navigations: same IP. A new context for each visit: a new IP each time. Use the first when a site should see one steady visitor, and the second when each visit should look separate.

Know the limits

  • The datacenter tier is US only and has no sessions. A site that checks the reputation of an address may block it. If you see 403 or a challenge page, use a residential tier such as standard.
  • A new IP does not clear cookies or storage. A new context does, which is part of why it works well here.

Errors

What you see What it means
ERR_TUNNEL_CONNECTION_FAILED with a 407 The API key is wrong or missing.
ERR_TUNNEL_CONNECTION_FAILED with a 400 The password asked for something this tier does not do: a country other than US, a session or a TTL.
A page returns 403 The site is refusing datacenter addresses.
A 400 that names an unknown tier The tier word is a close misspelling of a real tier, such as datacentre. Fix the spelling. A password that is not close to any tier, such as x, uses your account's default tier.

Related

  • Datacenter proxies with Puppeteer
  • Proxy connection format and tiers
  • Datacenter proxies

Try your next connection.

Free proxy credit for eligible new proxy users. No card required. Review the amount and conditions before claiming.

Get free proxy credit →

Explore proxy tiers and paid credit

Related

Proxies: your first requestFind your credentials, copy a cURL or Python example, and check the response.Proxy connection format and tiersWhat goes in the username and password, and what each tier is for.Using SOCKS5Port 1080, the same credentials, and the two things SOCKS5 cannot do.

Still stuck? Open a ticket — tell us what was missing and the article gets fixed.

PRIVATEBYTE

Infrastructure for independent minds.

Service status

Products

Virtual serversProxiesGet free proxy creditAgentsMigration

Resources

Looking glassSecurityBlogNews

Free tools

What is my IPProxy checkerPort checkerDomain checkerDNS lookupPassword generatorVPS price calculator

Company

AboutContactX / TwitterTelegram
© 2026 PrivateByte Ltd
TermsPrivacyAcceptable useRefundsAbuse & legalSLA

Registered in England & Wales · Company no. 15834803 · 128 City Road, London EC1V 2NX