Proxy Authentication in Puppeteer and Playwright: Setup and Errors
Both libraries drive a browser, and Chromium does not take a username and password from the proxy address. So credentials are passed separately, and each library does it in its own way.
Updated · Prokso editorial team
- The --proxy-server flag does not accept a username and password: Chromium drops such an address
- In Puppeteer the username is passed by page.authenticate(), in Playwright by the username and password fields of the proxy option
- SOCKS5 with a username does not work in Chromium: use HTTP port 823 or IP access
What the error means
The --proxy-server flag accepts only a scheme, host and port. The Chromium source code drops a proxy address with a username and password, so the string http://USERNAME:PASSWORD@gw.prokso.com:823 ends with net::ERR_NO_SUPPORTED_PROXIES.
In Puppeteer, credentials are passed with page.authenticate({username, password}). According to the documentation, it provides credentials for HTTP authentication, and to do so it turns on request interception behind the scenes, which might affect performance. The method belongs to a page, so call it for each new page before page.goto().
In Playwright, the proxy is set with the proxy: {server, username, password} option. The documentation says HTTP(S) and SOCKSv5 are supported, the proxy can be set for the whole browser or for a single context, and the username and password are described only for HTTP(S) proxies. The short form gw.prokso.com:823 is considered an HTTP proxy.
Causes
- A username in --proxy-server. Chromium drops such an address, and the browser is left without a proxy: net::ERR_NO_SUPPORTED_PROXIES.
- Missing or wrong credentials. Code -338 net::ERR_INVALID_AUTH_CREDENTIALS in Chromium means credentials could not be established during HTTP authentication. Check that authentication is called and that the username and password are correct; about the code itself, see the 407 page.
- The browser did not reach the proxy. Code -130 net::ERR_PROXY_CONNECTION_FAILED means a connection to the proxy server could not be created: an error in resolving its name or in connecting a socket. In Firefox under Playwright, the counterpart is NS_ERROR_PROXY_CONNECTION_REFUSED: the connection attempt to a proxy failed.
- SOCKS5 with a username in Chromium. Chromium does not support authentication for SOCKSv5, so page.authenticate() will not help here: the handshake ends with a SOCKS error.
- The tunnel did not open. If the connection to the proxy works but CONNECT to the site fails, you get ERR_TUNNEL_CONNECTION_FAILED.
How to fix it
- Puppeteer: launch with
--proxy-server=http://gw.prokso.com:823, then callawait page.authenticate({username: 'USERNAME', password: 'PASSWORD'})before navigating to the site. A full example is in the Puppeteer guide. - Playwright: pass
proxy: {server: 'http://gw.prokso.com:823', username: 'USERNAME', password: 'PASSWORD'}tolaunch(). Details in the Playwright guide. - For SOCKS5 in Chromium, turn on IP access (up to 5 addresses in the dashboard) and use
socks5://gw.prokso.com:824without a username, or switch to HTTP port 823 with a username. - If you need one IP for the whole script, use a port from the 10000-20000 range: it keeps a sticky IP for the session duration (1-120 min, 30 by default). More in sticky session.
- If you see ERR_PROXY_CONNECTION_FAILED, check the host gw.prokso.com, the port and the network using the proxy connection error page.
How to check that it works
After launch, open https://prokso.com/ip in the same page and read the JSON: the ip, country and org fields should belong to the proxy, not to your own connection. You can see the same on the IP check page.
Two-minute diagnosis
First paste the line into the proxy checker. If the proxy works there, the cause is in your app or its settings. If not, test the line from a terminal:
curl -v -x "http://USERNAME:PASSWORD@gw.prokso.com:823" https://api.ipify.org
- A
< HTTP/1.1 407line right afterCONNECTmeans the proxy answered. The name after the code, for exampleNO_USER, points to the cause. - The proxy answered
CONNECTwith 200 and then another code arrived - the proxy works, and that answer came from the website. - No answer at all, only a timeout - the connection never reached the proxy: check the host, port and network.
Setup guides where this error comes up
FAQ
Can I set different proxies for different tabs?
The --proxy-server flag sets the proxy for the whole browser. In Playwright the documentation allows setting a proxy for a single context too, so different contexts can go through different ports.
Why does page.authenticate() not work with SOCKS5?
The method answers an HTTP authentication request. Chromium does not support authentication for SOCKSv5, so there is simply no login request. Use the HTTP port or IP access.
Where do I get the username and password?
Copy the proxy string in the dashboard on the plan page. How the username is built and which parameters go into it is explained on the <a href="/en/help/gateway">gateway</a> page.
Other proxy errors
Residential $1.59, mobile $2.50, datacenter $0.65 per GB
Sign up in a minute, get access right after payment.