# How to Use a Proxy in Playwright (Python & Node.js)

Set up a proxy in Playwright for Python and Node.js: authentication, per-context and per-page IPs, SOCKS5 and HTTPS proxies, rotation and error fixes.

- Author: [Brandon Perry](https://fineproxy.org/brandon-perry/)
- Published: 2026-11-29T12:00:00.000Z
- Updated: 2026-11-29T12:00:00.000Z
- Canonical: https://fineproxy.org/articles/playwright-proxy/

To use a proxy in Playwright, pass a `proxy` object with `server`, `username` and `password` to `launch()` for the whole browser, or to `new_context()` for one context. Don't put the login and password into the server URL. Playwright drops them there, the proxy rejects the connection, and in Chromium the page usually just hangs until the timeout.

Two more things trip people up. SOCKS5 works in Playwright only without a password. And each browser context can have its own proxy, so one browser can open pages from several IP addresses at once.

We checked every example in this article with Playwright 1.65 (Python 1.65.2 and Node.js 1.65.1) in Chromium 159, Firefox 159 and WebKit 27.2 on Debian 12, in November 2026. We used real FineProxy proxies over HTTP, HTTPS and SOCKS5, both with a password and with IP whitelisting. The error messages below are copied from those runs.

## Where to set the proxy in Playwright

Playwright accepts the same `proxy` object in four places:

| Method (Python / Node.js) | What uses the proxy |
| --- | --- |
| `browser_type.launch(proxy=...)` / `launch({ proxy })` | Every context and page of this browser |
| `browser.new_context(proxy=...)` / `newContext({ proxy })` | All pages in this context |
| `browser.new_page(proxy=...)` / `newPage({ proxy })` | This page (Playwright creates a separate context for it) |
| `launch_persistent_context(dir, proxy=...)` / `launchPersistentContext(dir, { proxy })` | A browser with a saved profile |

The object has four fields:

| Field | Required | What it does |
| --- | --- | --- |
| `server` | Yes | Proxy address, such as `http://host:8080`, `https://host:8443` or `socks5://host:1080`. Without a scheme, `host:8080` is treated as `http://` |
| `username` | No | Proxy login. It works for `http://` and `https://` proxies. With `socks5://`, Playwright refuses it |
| `password` | No | Proxy password, with the same rules |
| `bypass` | No | Comma-separated hosts that go directly, without the proxy, for example `"localhost,127.0.0.1,.example.com"` |

A proxy set on a context replaces the one set at launch. We checked this the hard way: we launched the browser with a proxy that didn't work, gave the context a working one, and the pages opened through the context's proxy. A context can't switch the launch proxy off, though. If some contexts must connect directly, launch the browser without a proxy and set it only on the contexts that need it.

## Playwright proxy in Python

Here is the minimal example with the synchronous API. It opens `api.ipify.org`, which returns the IP address the site sees:

```python
from playwright.sync_api import sync_playwright

PROXY = {
    "server": "http://HOST:PORT",
    "username": "USER",
    "password": "PASS",
}

with sync_playwright() as p:
    browser = p.chromium.launch(proxy=PROXY)
    page = browser.new_page()
    page.goto("https://api.ipify.org?format=json")
    print(page.inner_text("body"))
    browser.close()
```

If the proxy works, you will see the proxy's IP, not yours. The async version is the same, only with `await`:

```python
import asyncio
from playwright.async_api import async_playwright

PROXY = {
    "server": "http://HOST:PORT",
    "username": "USER",
    "password": "PASS",
}


async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch(proxy=PROXY)
        page = await browser.new_page()
        await page.goto("https://api.ipify.org?format=json")
        print(await page.inner_text("body"))
        await browser.close()

asyncio.run(main())
```

To switch the browser, replace `p.chromium` with `p.firefox` or `p.webkit`. The `proxy` object stays the same.

Use the proxy at launch when the whole script needs one IP. When you need several IPs, or some pages must go directly, launch the browser without a proxy and set it on each context, as shown [below](#per-context-and-per-page-proxies).

## Playwright proxy in Node.js and TypeScript

In a Node.js script, the code looks almost the same. The examples use `import` and top-level `await`, so save them as `.mjs` files or add `"type": "module"` to `package.json`:

```js
import { chromium } from 'playwright';

const browser = await chromium.launch({
  proxy: {
    server: 'http://HOST:PORT',
    username: 'USER',
    password: 'PASS',
  },
});
const page = await browser.newPage();
await page.goto('https://api.ipify.org?format=json');
console.log(await page.textContent('body'));
await browser.close();
```

A proxy for one context and a persistent profile with a proxy look like this:

```js
import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext({
  proxy: { server: 'http://HOST:PORT', username: 'USER', password: 'PASS' },
});
const page = await context.newPage();
await page.goto('https://api.ipify.org?format=json');
console.log(await page.textContent('body'));
await browser.close();

const persistent = await chromium.launchPersistentContext('./profile-fi', {
  proxy: { server: 'http://HOST:PORT', username: 'USER', password: 'PASS' },
});
const page2 = await persistent.newPage();
await page2.goto('https://api.ipify.org?format=json');
console.log(await page2.textContent('body'));
await persistent.close();
```

### Proxy in Playwright Test

If you write tests with Playwright Test, put the proxy into `use` in `playwright.config.ts`. Playwright Test launches the browser with it, so the `page` fixture uses the proxy, and so does a context you create yourself with `browser.newContext()` in a test. We checked both.

For geo tests, give each country its own project. Each project gets its own proxy, language and time zone, and the password stays in environment variables:

```ts
import { defineConfig } from '@playwright/test';

const proxy = (server: string) => ({
  server,
  username: process.env.PROXY_USER,
  password: process.env.PROXY_PASS,
});

export default defineConfig({
  projects: [
    {
      name: 'fi',
      use: { proxy: proxy('http://HOST_FI:PORT'), locale: 'fi-FI', timezoneId: 'Europe/Helsinki' },
    },
    {
      name: 'de',
      use: { proxy: proxy('http://HOST_DE:PORT'), locale: 'de-DE', timezoneId: 'Europe/Berlin' },
    },
  ],
});
```

With this config, `npx playwright test` ran every test twice. In the `fi` project the page saw the Finnish IP and the `Europe/Helsinki` time zone, and in the `de` project it saw the German IP and `Europe/Berlin`. Run one country with `--project=de`.

## Proxy authentication in Playwright

Playwright logs in to a proxy only with the separate `username` and `password` fields. Writing them into the URL is the most common mistake, so here is what happened when we used `http://USER:PASS@HOST:PORT` as `server`. Playwright didn't throw an error at launch. It just didn't send the credentials, and the proxy rejected the connection:

| Browser | What `page.goto("https://...")` did |
| --- | --- |
| Chromium, default headless mode | Hung until the timeout: `Page.goto: Timeout 30000ms exceeded.` |
| Chromium with a window, or `channel="chromium"` | `net::ERR_INVALID_AUTH_CREDENTIALS` |
| Firefox | `NS_ERROR_PROXY_CONNECTION_REFUSED` |
| WebKit | `Page.goto: Download is starting` |

A missing password gave exactly the same results. A wrong password differed only in full Chromium, which reported `net::ERR_HTTP_RESPONSE_CODE_FAILURE`. Why are there two rows for Chromium? By default, headless Playwright runs a stripped-down build called Chromium Headless Shell, and only that build hangs. A window, or `channel="chromium"` in headless mode, runs the full browser, which fails right away.

The other way to log in is **IP whitelisting**. You add your server's IP to the list of allowed addresses at your proxy provider, and the proxy accepts connections from it without a password. Then the `proxy` object has only `server`. This is also the only way to give a browser in Playwright a `socks5://` proxy that requires authorization, as you'll see below. The downside is that it works only from a machine with a fixed IP address. FineProxy has [proxies with IP authorization](/proxy/ip-authorized-proxies/) for this.

The `http_credentials` option doesn't help with a proxy. It answers a website's 401 request, not the proxy's 407.

## Per-context and per-page proxies

The proxy in Playwright belongs to a browser context. A context is like a separate browser profile, with its own cookies and storage. So one browser can hold several contexts, each going out through its own IP:

```python
from playwright.sync_api import sync_playwright

PROXIES = [
    {"server": "http://HOST1:PORT", "username": "USER", "password": "PASS"},
    {"server": "http://HOST2:PORT", "username": "USER", "password": "PASS"},
    None,  # this context connects directly
]

with sync_playwright() as p:
    browser = p.chromium.launch()
    for proxy in PROXIES:
        context = browser.new_context(proxy=proxy) if proxy else browser.new_context()
        page = context.new_page()
        page.goto("https://api.ipify.org?format=json")
        print(proxy and proxy["server"], "->", page.inner_text("body"))
        context.close()
    browser.close()
```

In our test, the two proxied contexts showed the proxy's IP, and the third one showed the server's own address. Note that the browser itself is launched without a proxy, as in Playwright's own example. Some older guides launch it with a placeholder proxy first. We didn't need that in any of the three browsers on Linux.

Can you set a proxy for a single page? There is no proxy option on `context.new_page()`: all pages in a context share its proxy. But `browser.new_page()` accepts the same options as a context, including `proxy`, because Playwright creates a separate context for that page:

```python
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    proxied = browser.new_page(proxy={"server": "http://HOST:PORT", "username": "USER", "password": "PASS"})
    direct = browser.new_page()
    for page in (proxied, direct):
        page.goto("https://api.ipify.org?format=json")
        print(page.inner_text("body"))
    browser.close()
```

The first page went through the proxy and the second one went directly, in Chromium, Firefox and WebKit alike. Pages opened this way don't share cookies, because each one sits in its own context. When you close such a page, Playwright closes its context too.

## Persistent context with a proxy (launch_persistent_context)

A persistent context keeps the profile in a folder between runs: cookies, local storage and logins. Its method takes the proxy directly, because it starts the browser and the context together:

```python
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    context = p.chromium.launch_persistent_context(
        "./profile-de",
        proxy={"server": "http://HOST:PORT", "username": "USER", "password": "PASS"},
    )
    page = context.new_page()
    page.goto("https://api.ipify.org?format=json")
    print(page.inner_text("body"))
    context.close()
```

This worked with a password in all three browsers. A persistent context is the only context of its browser, so to change the proxy, close it and launch it again with the new one. Keep one IP per profile. If a site sees the same cookies arrive from a new country, it is more likely to show a captcha or ask you to log in again.

## SOCKS5, HTTPS and HTTP proxies: what works in each browser

This is the table we built from our runs. Every cell is a real request to `api.ipify.org` through the proxy:

| Proxy and login method | Chromium 159 | Firefox 159 | WebKit 27.2 (Linux) |
| --- | --- | --- | --- |
| HTTP, username and password | Works | Works | Works |
| HTTP, login and password inside the URL | Fails | Fails | Fails |
| HTTP, IP whitelisting | Works | Works | Works |
| HTTPS (TLS to the proxy), username and password | Works | Works | Fails |
| HTTPS, IP whitelisting | Works | Works | Fails |
| SOCKS5, username and password | Error at launch | Error at launch | Error at launch |
| SOCKS5, IP whitelisting | Works | Works | Works |
| SOCKS4, IP whitelisting | Works | Works | Works |

### SOCKS5 with a password doesn't work

If you pass `socks5://` together with `username` and `password`, Playwright refuses before the browser even starts:

```text
BrowserType.launch: Browser does not support socks5 proxy authentication
```

On a context, the message starts with `Browser.new_context:` instead. It's the same in all three browsers and in both Python and Node.js. Users asked Playwright for SOCKS5 authentication back in 2021. The request was closed in 2026 during a cleanup of old issues, and version 1.65 still doesn't support it.

There are three ways around it:

- **Use the HTTP or HTTPS endpoint of the same proxy.** Most providers give one IP on several protocols. With HTTP or HTTPS, the password works.
- **Use SOCKS5 with IP whitelisting.** Then `server` is enough:

```python
browser = p.firefox.launch(proxy={"server": "socks5://HOST:PORT"})
```

- **Run a local bridge.** A small program such as gost accepts a connection without a password on your machine and forwards it to the real proxy with the password. We showed this setup in our article about [SOCKS proxies in Claude Code](/articles/claude-code-socks-proxy/).

When you pass `socks5://` to `launch()` in Chromium, Playwright also adds a launch flag that stops Chromium from resolving domain names locally, so DNS lookups go through the proxy. You can see this rule in Playwright's source code. It's added only at launch, not when you set a SOCKS5 proxy on a context.

### An HTTPS proxy encrypts the connection to the proxy

With an `http://` proxy, the connection from your browser to the proxy is not encrypted. Your traffic to an `https://` website is still encrypted inside the tunnel, but the proxy password and the name of the site you open travel in clear text. With an `https://` proxy, the browser first opens a TLS connection to the proxy itself, so that part is encrypted too.

FineProxy has these: its [HTTPS proxies](/proxy/https-proxies/) come with a separate SSL certificate on each IP, and we tested the examples in this section on them.

To use it, write `https://` in `server`:

```python
PROXY = {
    "server": "https://proxy.example.com:PORT",
    "username": "USER",
    "password": "PASS",
}
```

Two things matter here:

- **Connect by the domain name from the proxy's certificate, not by IP.** When we used the bare IP, all three browsers refused the certificate: `net::ERR_PROXY_CERTIFICATE_INVALID` in Chromium, `SSL_ERROR_BAD_CERT_DOMAIN` in Firefox, `Unacceptable TLS certificate` in WebKit.
- **Don't use `http://` for a TLS port.** The connection breaks: `net::ERR_EMPTY_RESPONSE` in Chromium, `NS_ERROR_NET_RESET` in Firefox, `Connection terminated unexpectedly` in WebKit.

WebKit on Linux rejected the proxy's certificate even with the correct domain name, though the same certificate passed in Chromium, Firefox and curl. We tested only the Linux build of WebKit, so it may behave differently on macOS. If you need WebKit on Linux, use an HTTP or SOCKS5 proxy for it.

### Which proxy schemes the browsers accept

The schemes Playwright accepts depend on the browser. We checked the less common ones on a local test proxy:

| Scheme | Chromium | Firefox | WebKit (Linux) |
| --- | --- | --- | --- |
| `http://`, `https://`, `socks5://`, `socks4://` | Works | Works | Works (except `https://`) |
| `socks://` | Works | `NS_ERROR_NET_RESET` | Works |
| `socks4a://` | `net::ERR_NO_SUPPORTED_PROXIES` | `NS_ERROR_NET_RESET` | Works |
| `socks5h://` | `net::ERR_NO_SUPPORTED_PROXIES` | `NS_ERROR_NET_RESET` | `Proxy protocol “socks5h” is not supported.` |

`socks5h://` comes up often, because that's how curl and Python's `requests` ask for DNS through the proxy. In Playwright, write plain `socks5://`.

## Bypass list: which sites skip the proxy

The `bypass` field lists hosts that go directly. Separate them with commas. A domain with a leading dot, such as `.example.com`, matches its subdomains, so add the bare domain separately if you need it too:

```python
PROXY = {
    "server": "http://HOST:PORT",
    "username": "USER",
    "password": "PASS",
    "bypass": "localhost,127.0.0.1,api.ipify.org",
}
```

With this setting, a page in the same browser opened `api.ipify.org` with our server's real IP, and `icanhazip.com` with the proxy's IP. It worked the same way in all three browsers, and so did `.ipify.org`.

**Add `localhost` and `127.0.0.1` if you test a local app.** Without them, Playwright sends even local addresses to the proxy. In our test, `http://127.0.0.1:18555/` and `http://localhost:18555/` got a 503 response from the proxy in all three browsers, and with the bypass they opened the local server.

## Rotating proxies in Playwright

There are two ways to get a new IP. The first is to rotate on your side: keep a list of proxies and give each new context the next one. The browser stays open, and creating a context is much faster than launching a browser:

```python
import itertools
from playwright.sync_api import sync_playwright

PROXIES = itertools.cycle([
    {"server": "http://HOST1:PORT", "username": "USER", "password": "PASS"},
    {"server": "http://HOST2:PORT", "username": "USER", "password": "PASS"},
])
URLS = ["https://api.ipify.org?format=json"] * 4

with sync_playwright() as p:
    browser = p.chromium.launch()
    for url in URLS:
        context = browser.new_context(proxy=next(PROXIES))
        page = context.new_page()
        page.goto(url)
        print(page.inner_text("body"))
        context.close()
    browser.close()
```

The second is to let the proxy rotate, so you don't need the list and the loop above. A rotating proxy gives you one gateway address, and the provider changes the outgoing IP behind it. In Playwright, it looks like a regular HTTP proxy with a password: put the gateway address in `server`, and the rest of the code stays the same. For example, [FineProxy rotating proxies](/proxy/unlimited-rotating-proxies/) give you a new IP on every request on the gateway's regular ports, while sticky ports keep one IP for a session (15 minutes by default).

Can you get a new proxy for every request? Not inside one context: Playwright fixes the proxy when the context is created. A rotating gateway can change the IP on its side, but then one page load may come from several addresses, because the page loads its images and scripts in separate requests. That's fine for collecting public pages. On sites with a login, the session will break. For logins, use a sticky session, which keeps one IP for a while, or a static IP, and give each session its own context.

## Installing Playwright browsers behind a proxy

The `playwright install` command downloads browsers from Playwright's CDN, and it reads `HTTPS_PROXY`:

```bash
HTTPS_PROXY="http://USER:PASS@HOST:PORT" python -m playwright install chromium
```

Here the password inside the URL works, because it's an environment variable for the downloader, not the browser's `proxy` option. In Node.js, run `npx playwright install chromium` with the same variable. With a wrong password, the download fails with a clear message:

```text
Error: Download failed: server returned code 407 body ''. URL: https://cdn.playwright.dev/builds/cft/...
```

## Environment variables: HTTP_PROXY, HTTPS_PROXY and NO_PROXY

Playwright's `proxy` option doesn't read environment variables, but the browsers it starts might. This is what we saw on Linux when a script set no `proxy` and the environment had a proxy variable:

| Variable | Chromium (both builds) | Firefox | WebKit |
| --- | --- | --- | --- |
| `HTTPS_PROXY` or `https_proxy` | Uses it | Uses it | Ignores it |
| `ALL_PROXY=socks5://...` | `net::ERR_CONNECTION_RESET` | Ignores it | Ignores it |

This matters in CI and in AI agents. If the job or the agent runs with `HTTPS_PROXY` for its own traffic, the browser may silently go out through that proxy too. When you pass the `proxy` option, it takes priority over the variables. To make a browser connect directly, set `NO_PROXY=*` for its process. On macOS and Windows, Chromium uses the system proxy settings instead. We tested only Linux.

## Common Playwright proxy errors

The messages below are what Playwright printed in our runs. If you don't know where to start, run the same script in Chromium: its error codes are the most specific.

### Timeout on page.goto (407 in Chromium)

```text
Page.goto: Timeout 30000ms exceeded.
```

**Cause.** If the proxy needs a password and doesn't get a valid one, Chromium Headless Shell doesn't report the 407 for `https://` pages. It waits until the timeout, which is 30 seconds by default. We got this with a wrong password, with no password, and with the password written inside the URL. Full Chromium reports `net::ERR_INVALID_AUTH_CREDENTIALS` instead. On a plain `http://` page, Chromium and WebKit return a response with status 407 and an empty body.

**Fix.** Check the login and password, and pass them in the `username` and `password` fields.

### NS_ERROR_PROXY_CONNECTION_REFUSED (Firefox)

**Cause.** Firefox uses this code for two different problems: the proxy rejected the password, or nothing listens on the proxy port.

**Fix.** Run the same script in Chromium. `net::ERR_PROXY_CONNECTION_FAILED` there means the port is wrong. A `Page.goto` timeout or `net::ERR_INVALID_AUTH_CREDENTIALS` means the password is wrong.

### net::ERR_TUNNEL_CONNECTION_FAILED

**Cause.** The proxy accepted the connection but refused to open a tunnel to the site. In our tests, the proxy answered `CONNECT` with 403 (target not allowed) or 502 (the proxy couldn't reach the site). Firefox reports these as `NS_ERROR_PROXY_FORBIDDEN` and `NS_ERROR_PROXY_BAD_GATEWAY`.

**Fix.** Check that your plan allows the site and port you are opening, then try the same request with curl through the proxy. If curl gets the same 403 or 502, the problem is on the proxy side.

### net::ERR_PROXY_CONNECTION_FAILED

**Cause.** The browser couldn't connect to the proxy at all. Either nothing is listening on that port, or the host name doesn't resolve. WebKit separates the two cases:

| Situation | WebKit message |
| --- | --- |
| Port closed | `Could not connect to proxy server ...: Connection refused` |
| Host doesn't resolve | `Error resolving “...”: Name or service not known` |

Firefox reports a host that doesn't resolve as `NS_ERROR_UNKNOWN_PROXY_HOST`.

**Fix.** Check the host and port. If a firewall drops the packets instead of closing the port, Chromium fails with `net::ERR_TIMED_OUT`.

### net::ERR_NO_SUPPORTED_PROXIES

**Cause.** Chromium doesn't know the scheme in `server`. We got it with `socks5h://` and `socks4a://`.

**Fix.** Write `socks5://` or `socks4://`.

### ERR_PROXY_CERTIFICATE_INVALID

**Cause.** You connect to an `https://` proxy by IP, or by a name that isn't in its certificate.

**Fix.** Use the domain name from the proxy's certificate. Firefox reports this case as `SSL_ERROR_BAD_CERT_DOMAIN`.

### Browser does not support socks5 proxy authentication

**Cause.** `socks5://` with `username` and `password`.

**Fix.** Switch to HTTP or HTTPS with the same password, or to SOCKS5 with IP whitelisting.

### Download is starting (WebKit)

**Cause.** This WebKit message doesn't mean a download. In our tests, WebKit printed it whenever the proxy answered `CONNECT` with an error: 403, 407 or 502.

**Fix.** Run the same script in Chromium to see which of the cases above you've hit.

## Using Playwright with an AI agent (MCP)

If an AI agent drives the browser through Playwright MCP, you set the proxy in the MCP server's settings instead of the code. For example, `--proxy-server http://USER:PASS@HOST:PORT` in the server's arguments. Unlike the library, Playwright MCP 0.0.86 does accept the login and password inside this URL: in our test, it passed them on, and the browser went out through the proxy.

The agent can also set up the proxy for itself, if a second MCP server gives it access to your proxy account. For example, the FineProxy MCP server can add the agent's IP to the whitelist. We tested both setups, by hand and by the agent, in [our guide to Playwright MCP with a proxy](/articles/playwright-mcp-proxy/).

## Which proxy to choose for Playwright

Start with the job the browser does:

- **Checking your own site from other countries, monitoring, collecting public pages.** [Datacenter proxies](/datacenter-proxies/) are the cheapest and fastest option. Sites with strict bot protection flag them more often.
- **Accounts, logins and long sessions.** [ISP proxies](/proxy/static-residential-proxies/) keep one IP for as long as you need. Their addresses are registered to internet providers rather than hosting companies.
- **Large-scale scraping.** [Rotating proxies](/proxy/unlimited-rotating-proxies/) give you one gateway with a pool of IPs behind it: the gateway changes the IP, not your code, as described in the [rotation section](#rotating-proxies-in-playwright).

Then pick the protocol. Standard [HTTP proxies](/proxy/http-proxies/) work in every Playwright browser with a password. [HTTPS proxies](/proxy/https-proxies/) have an SSL certificate on every IP and encrypt the connection from Playwright to the proxy, which worked in Chromium and Firefox in our tests. [SOCKS5 proxies](/proxy/socks5-proxies/) work in Playwright with IP whitelisting.

## Frequently asked questions

### Does Playwright support SOCKS5 proxies?

Yes, but only without a password. In Playwright 1.65, a socks5:// server with no credentials worked in Chromium, Firefox and WebKit. If you add username and password, Playwright throws “Browser does not support socks5 proxy authentication” when it launches the browser or creates the context. Use an HTTP or HTTPS proxy with a password, or a SOCKS5 proxy with IP whitelisting.

### Can I set a different proxy for each page in Playwright?

Yes. The proxy belongs to a browser context, and browser.new_page(proxy=...) in Python or browser.newPage({ proxy }) in Node.js creates a page with its own context. Pages opened with context.new_page() share the proxy of their context. To give several pages different IPs, open each one in its own context.

### Why does my Playwright proxy return 407?

The proxy didn't get valid credentials: they are wrong, missing, or written inside the server URL, which Playwright ignores. Put the login and password into the username and password fields. You may not see the 407 itself: in Playwright 1.65, default headless Chromium hangs until the timeout on https:// pages, full Chromium reports net::ERR_INVALID_AUTH_CREDENTIALS or net::ERR_HTTP_RESPONSE_CODE_FAILURE, and Firefox reports NS_ERROR_PROXY_CONNECTION_REFUSED.

### Why is my Playwright proxy not working?

Check four things in this order. The scheme in server matches the port: http://, https:// or socks5://. The login and password are in the username and password fields, not in the URL. SOCKS5 is used without a password. For an https:// proxy, the host is the domain name from its certificate, not the IP. Then open api.ipify.org to see which IP the page actually uses.

### Can I change the proxy without restarting the browser?

Yes. Launch the browser without a proxy and create a new context with a different proxy option. Creating a context is much faster than launching a browser, and the browser keeps running. Inside one existing context, the proxy can't be changed.

### Does Playwright use the HTTP_PROXY and HTTPS_PROXY environment variables?

Not through its own proxy option, but the browsers may read them. On Linux in our tests with Playwright 1.65, Chromium and Firefox used HTTPS_PROXY when the script didn't pass a proxy, and WebKit ignored it. The playwright install command also reads HTTPS_PROXY. Pass the proxy option explicitly, and set NO_PROXY=* if the browser must connect directly.

### Can I use an HTTPS proxy with Playwright?

Yes. Write https:// in the server field and connect by the domain name from the proxy's certificate: with a bare IP, all browsers reject the certificate. In Playwright 1.65, Chromium and Firefox then opened an encrypted connection to the proxy. WebKit on Linux failed with “Unacceptable TLS certificate” even with the correct domain.
