Playwright proxy setup
Playwright takes the proxy address, login and password in one `proxy` option, for the whole browser or per context. Examples for Python and Node.js.
- Protocols
- HTTP proxy on port 7000 with a login (HTTPS sites through CONNECT). SOCKS5 only without a login
- Authentication
usernameandpasswordin theproxyoption- Rotation
- A sticky
-sid-login: one IP per browser or per context, for up to 60 minutes - Works with
- Residential and mobile proxies
Before you start
- Python:
pip install playwright, thenplaywright install chromium. Node.js:npm i playwright, thennpx playwright install chromium. - Your proxy login and password from the Residential or Mobile page of the dashboard.
- Traffic on the product you use: a login without traffic gets 402.
- Host
gate.aeonproxy.com- Port (HTTP / HTTPS)
7000- Login
- your proxy login, with targeting keys if you need them:
LOGIN-cc-us-sid-abc123 - Password
- your proxy password
Copy the login and password from the Residential or Mobile page of the dashboard; the generator there also writes ready lines. Key syntax: targeting and sessions.
Python: one proxy for the browser
Pass proxy to launch. The login goes into username, not into the server address.
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(proxy={
"server": "http://gate.aeonproxy.com:7000",
"username": "LOGIN-cc-us-sid-ab12cd34-ttl-30",
"password": "PASSWORD",
})
page = browser.new_page()
page.goto("https://api.ipify.org")
print(page.inner_text("body"))
browser.close()The async API (playwright.async_api) takes the same dictionary.
Python: one IP per context
Each browser context can have its own proxy login, so its own country, sticky IP and cookies. One browser process serves them all.
import secrets
from playwright.sync_api import sync_playwright
def proxy(country):
return {
"server": "http://gate.aeonproxy.com:7000",
"username": f"LOGIN-cc-{country}-sid-{secrets.token_hex(4)}-ttl-30",
"password": "PASSWORD",
}
with sync_playwright() as p:
browser = p.chromium.launch()
for country in ("us", "de", "jp"):
context = browser.new_context(proxy=proxy(country)) # its own IP and cookies
page = context.new_page()
page.goto("https://api.ipify.org")
print(country, page.inner_text("body"))
context.close()
browser.close()Node.js
import { chromium } from "playwright";
const browser = await chromium.launch({
proxy: {
server: "http://gate.aeonproxy.com:7000",
username: "LOGIN-cc-us-sid-ab12cd34-ttl-30",
password: "PASSWORD",
},
});
const page = await browser.newPage();
await page.goto("https://api.ipify.org");
console.log(await page.innerText("body"));
await browser.close();browser.newContext({ proxy }) takes the same object, for one IP per context as in the Python example.
Playwright Test
In a test project, put the proxy under use in playwright.config.ts and every test gets it:
import { defineConfig } from "@playwright/test";
export default defineConfig({
use: {
proxy: {
server: "http://gate.aeonproxy.com:7000",
username: "LOGIN-cc-us-sid-ab12cd34-ttl-30",
password: "PASSWORD",
},
},
});SOCKS5
Playwright refuses a SOCKS5 proxy with a login: launch fails with Browser does not support socks5 proxy authentication. The gateway's SOCKS5 port needs a login, so use the HTTP port 7000.
Rotating or sticky
One page opens many connections, and a rotating login gives each of them a new IP. Use a sticky login as in the examples, and a new key when you need a new IP: a new context is enough, the browser can keep running. To check the exit, open IP checker in the page.
If it does not work
| What you see | What to check |
|---|---|
page.goto: Timeout 30000ms exceeded on the first page | Usually the login: with a wrong login, password or key Chromium waits on the proxy's 407 instead of failing. |
net::ERR_TUNNEL_CONNECTION_FAILED | The gateway refused the tunnel, and Chrome does not show the code: usually 402 (no traffic left), 403 (a target blocked by default) or 502 (the exit failed, retry). curl with the same login prints it: CONNECT tunnel failed, response 402. |
Browser does not support socks5 proxy authentication | Use http://gate.aeonproxy.com:7000 as the server. |
| One page shows different IPs | A rotating login. Add -sid- with a key. |
Questions
Yes. Give each context its own username with its own -cc- key, as in the context example. Bought traffic has no thread limit, so contexts and browsers can run in parallel.
Yes, proxy is an option of every browser type in Playwright. We ran the examples with Chromium.