ProxyZen

Proxy in Puppeteer, Playwright, Selenium and curl: code examples

28 November 2026 · 3 min read

How to use an HTTP or SOCKS5 proxy with a username and password in Puppeteer, Playwright, Selenium and curl, with code examples and common errors.

Ready-made examples for browser automation and the command line. In the examples, HOST, PORT, USER and PASS are the data from “My proxies” in the ProxyZen dashboard. Every ProxyZen IPv4 and IPv6 proxy supports HTTP and SOCKS5.

curl

# HTTP proxy
curl -x http://USER:PASS@HOST:PORT https://api.ipify.org

# SOCKS5, DNS resolved on the proxy side
curl -x socks5h://USER:PASS@HOST:PORT https://api.ipify.org

# login and password separately
curl -x http://HOST:PORT -U USER:PASS https://api.ipify.org

socks5h instead of socks5 means website names are resolved by the proxy, not by your computer. If the password contains special characters (@, :, #), URL-encode them or pass them with -U.

Puppeteer (Node.js)

Chrome does not accept a password in --proxy-server, so the login is passed with page.authenticate:

const puppeteer = require('puppeteer');

const browser = await puppeteer.launch({
  args: ['--proxy-server=http://HOST:PORT'],
});
const page = await browser.newPage();
await page.authenticate({ username: 'USER', password: 'PASS' });
await page.goto('https://api.ipify.org');
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();

For SOCKS5 with a password in Chrome, use an HTTP proxy instead: Chrome does not support SOCKS5 authentication.

Playwright (Node.js and Python)

Playwright accepts the login and password directly:

const { chromium } = require('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');
console.log(await page.textContent('body'));
await browser.close();
from playwright.sync_api import sync_playwright

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

You can also set a different proxy for each context: browser.new_context(proxy={...}) — convenient for several accounts in one process.

Selenium (Python)

Chrome in Selenium does not support a proxy password by itself. The simplest way is the selenium-wire package:

from seleniumwire import webdriver

options = {
    "proxy": {
        "http": "http://USER:PASS@HOST:PORT",
        "https": "http://USER:PASS@HOST:PORT",
    }
}
driver = webdriver.Chrome(seleniumwire_options=options)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()

Scrapy and BeautifulSoup

BeautifulSoup only parses HTML; the proxy is set in the library that downloads the page (requests, httpx). Examples: “How to use proxies in Python and Node.js”. In Scrapy, set request.meta["proxy"] = "http://USER:PASS@HOST:PORT".

Common errors

  • 407 Proxy Authentication Required — login or password not passed. See this guide.
  • ERR_NO_SUPPORTED_PROXIES in Chrome — SOCKS5 with a password. Use HTTP.
  • Timeouts — check the proxy in the proxy checker and the port in the port check.
  • 403 and CAPTCHAs — too many requests from one IP. See “Proxies for web scraping”.

Proxies can also be bought and renewed automatically through the ProxyZen API. Private IPv4 from $0.60, residential from $1.59 per GB. Buy proxies.

Try ProxyZen

Private IPv4 and IPv6 for 3 to 90 days, residential and mobile per GB. Instant delivery, HTTP(S) and SOCKS5.

Trustpilot Write a review