Integrations
Anything that speaks SOCKS5 works with p2proxy. Point it at socks5://localhost:1080 (or whatever port you’ve configured) and you’re done.
Playwright
import { chromium } from "playwright";
const browser = await chromium.launch({
proxy: { server: "socks5://localhost:1080" },
});
const page = await browser.newPage();
await page.goto("https://example.com");
For per-context proxies (Playwright ≥ 1.29):
const context = await browser.newContext({
proxy: { server: "socks5://localhost:1080" },
});
Puppeteer
Puppeteer takes proxy via launch args:
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({
args: ["--proxy-server=socks5://localhost:1080"],
});
curl
curl --socks5-hostname localhost:1080 https://example.com
Python requests (with PySocks)
import requests
proxies = {
"http": "socks5h://localhost:1080",
"https": "socks5h://localhost:1080",
}
r = requests.get("https://ifconfig.me", proxies=proxies)
print(r.text)
The socks5h:// scheme resolves DNS through the proxy. Use socks5:// if you want local resolution.
Chrome / Chromium
Launch Chrome with:
google-chrome \
--proxy-server="socks5://localhost:1080" \
--user-data-dir=/tmp/chrome-p2proxy
Use a fresh --user-data-dir so you don’t taint your normal profile.
Firefox
Settings → Network Settings → Manual proxy configuration → SOCKS Host: localhost, Port: 1080. Tick SOCKS v5 and Proxy DNS when using SOCKS v5.
Full-tunnel (every TCP connection through p2proxy)
Use tun2socks to route an entire interface through the SOCKS5 endpoint. This is the workaround for tools that don’t natively support SOCKS5.
High-level steps:
- Create a TUN device.
- Point
tun2socksatsocks5://localhost:1080. - Add a default route through the TUN device for the subnets you want to tunnel.
See the tun2socks README for the precise invocation on your platform.
Picking the right SOCKS5 dialect
Most tools speak SOCKS5 well, but DNS handling varies:
socks5://— client resolves DNS locally, then asks p2proxy for the IP.socks5h://— p2proxy (via the peer) resolves DNS. Use this when DNS resolution from your machine would itself leak which sites you’re visiting, or when local DNS would resolve differently from the peer’s location.
For most scraping / multi-geo workloads you want socks5h://.