Proxies with Selenium, Puppeteer & Playwright
Code examples for adding a RelayKit USA 4G/5G mobile proxy to your browser automation scripts. Covers Playwright (Python & JavaScript), Puppeteer, and Selenium (Python & Java).
Overview
RelayKit proxies support both HTTP and SOCKS5 protocols on fixed ports. Use the format below based on your framework.
Replace HOST, USERNAME, and PASSWORD with the values from your dashboard: relaykit.net/dashboard → Proxies tab → click your order.
For most scraping use cases, Playwright is recommended — it has the best cross-browser support, built-in async, and native authenticated proxy support with a clean API. Puppeteer requires a workaround for authenticated proxies. Selenium requires a browser extension or seleniumwire for username/password authentication.
Playwright (Recommended)
Playwright has first-class support for authenticated proxies — pass the proxy object directly to launch(). Works with HTTP and SOCKS5.
Python
JavaScript / Node.js
Puppeteer
Puppeteer doesn't natively support authenticated proxy credentials in launch() args. Pass the proxy server URL as a Chrome arg, then authenticate using page.authenticate().
Selenium
Selenium doesn't support authenticated proxies natively via ChromeOptions. The standard approach is to pass the proxy server without credentials in the Chrome args — then use seleniumwire (Python) for authenticated proxies.
Python (unauthenticated / seleniumwire)
Java
For authenticated proxies in Java, use a Chrome extension approach or BrowserMob Proxy. The simplest production approach remains IP whitelisting — add your server IP in RelayKit dashboard to skip credential auth entirely.
Using SOCKS5
SOCKS5 (port 9000) is supported by Playwright and most modern frameworks. Swap the server URL in your proxy config:
Tips for scraping with mobile proxies
Session management
RelayKit proxies are dedicated sticky lines — your IP stays the same for the entire rental period. This is ideal for scraping flows that require session continuity (login, pagination, checkout). If you need a fresh IP mid-scrape, use the dashboard's IP rotation button or set up auto-rotation.
Rotation strategy
For large-scale scraping across many targets, consider using multiple proxy orders across different US cities. Rotate between them in your code to distribute requests across carrier IPs. Each rotation from the dashboard gives you a new mobile IP.
Rate limiting
Even with mobile proxies, aggressive request rates can trigger bot detection. Add randomized delays between requests (500ms–3s is a common range). Mobile IPs raise your baseline trust score but won't override unrealistic request patterns.
IP whitelisting for production
In production environments, enable IP whitelisting on your RelayKit proxy and whitelist your server IP. This removes the need for credential-based auth in your code and adds a security layer — only your server can use the proxy.
- Dashboard → Proxies → click your order → Whitelist → add your server IP in CIDR notation (e.g. 1.2.3.4/32)
- Once whitelisted, you can omit username/password from your proxy URL
- Simpler code: http://HOST:8000 — no credentials needed
Get your RelayKit proxy
Real 4G/5G carrier IPs for Playwright, Puppeteer, and Selenium. 50+ US cities, unlimited bandwidth.