Configure a Playwright proxy with the proxy option when launching a browser or creating a browser context. Use server, username and password for an authenticated HTTP proxy. Website login credentials belong to a different configuration and should not be substituted for proxy authentication.
This Python guide builds one browser session and observes its connection before navigating to a permitted destination. It complements the browser setup guides for desktop profile applications.
Key points: start with one context and one page. Keep the endpoint and credentials in environment variables. An observed exit IP describes the request you made; it does not demonstrate anonymity or guarantee that a destination will accept the connection.
The Playwright network guide documents HTTP proxy configuration at browser and context level. The following example uses browser-level configuration so that the starting point is unambiguous.
Install the Python package with python -m pip install playwright, then install Chromium with python -m playwright install chromium. Your operating environment may need additional browser dependencies; follow the official installation instructions for that environment.
import os
from playwright.sync_api import sync_playwright
proxy = {
"server": os.environ["PROXY_SERVER"],
"username": os.environ["PROXY_USER"],
"password": os.environ["PROXY_PASSWORD"],
}
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, proxy=proxy)
context = browser.new_context()
page = context.new_page()
try:
response = page.goto(
"https://api.ipify.org?format=json",
wait_until="domcontentloaded",
timeout=30000,
)
if response is None:
raise RuntimeError("Navigation returned no response")
print("HTTP status:", response.status)
print(page.locator("body").inner_text())
finally:
context.close()
browser.close()
Set PROXY_SERVER to a complete endpoint such as http://proxy.example:3128, replacing it with your issued details. Keep the username and password in their separate fields. The IP lookup sends a request to ipify; substitute your own diagnostic endpoint if that better fits your environment.
Playwright also has an http_credentials setting for HTTP authentication. That setting and an application’s login form concern authentication at the website. Neither should be used as a substitute for the proxy’s username and password.
Keep a small configuration record with two headings: connection to the proxy, and authentication to the destination. This simple separation helps when an error is reported as “authentication failed” without saying which service rejected it. Share only sanitized fields when asking for help.
For an initial connectivity check, launch one browser with one proxy. Once that works, use the documented context-level option if your application needs isolated contexts with different settings. Avoid adding multiple profiles, parallel pages and custom routing at the same time as the first proxy configuration.
The BrowserType API reference describes the proxy fields and supported options. Match examples to the language binding you use: Python’s naming conventions differ from JavaScript’s. Do not copy a JavaScript object into Python and then diagnose the resulting syntax error as a proxy failure.
A successful initial response does not mean every subresource, redirect or later request succeeded. If navigation fails, record whether Playwright reports a timeout, a browser network error or an HTTP response. If the page loads but its content differs, inspect the application’s own conditions rather than assuming the proxy is disconnected.
Use a page you control as the second destination. Compare its server-side request record with the browser observation. If you enable tracing or save screenshots, treat the files as potentially sensitive: they can contain page content and session information.
The general proxy checking guide gives a separate endpoint-level diagnostic sequence. It is useful before investigating selectors, clicks or application state.
Do not turn an initial connection check into a large crawl. Add one permitted navigation after the diagnostic page, then the minimum interactions needed by your task. Keep concurrency and waiting behaviour deliberate. A browser context’s proxy setting does not establish permission to automate a destination or remove its access restrictions.
The network guide documents SOCKSv5 alongside HTTP proxy support. Authentication and browser-specific limitations still matter. The example above is intentionally limited to authenticated HTTP proxy configuration; do not assume that changing one scheme makes every authentication combination supported.
No. Identify which operation timed out and whether the initial diagnostic request succeeded. Navigation, page interactions and destination responses can fail for different reasons.
Open the bot, choose your plan and available country, then copy the issued connection settings into the appropriate fields. Open Proxyca in Telegram.