Hey everyone, I’m having a hard time setting up a proxy with Puppeteer. I’ve tried a couple of different approaches, but I keep running into the same error: ERR_NO_SUPPORTED_PROXIES
.
Here’s one of the ways I attempted to set it up:
const launchBrowser = async () => {
const browser = await puppeteer.launch({
headless: false,
args: ['--proxy-server=http://user:[email protected]:8080']
});
const page = await browser.newPage();
await page.goto('https://checkip.example.com');
await page.screenshot({ path: 'ip_check.png' });
};
launchBrowser();
I also tried authenticating separately:
const setupProxy = async () => {
const browser = await puppeteer.launch({
headless: false,
args: ['--proxy-server=proxyhost.example.com:8080']
});
const page = await browser.newPage();
await page.authenticate({
username: 'user',
password: 'pass'
});
await page.goto('https://checkip.example.com');
};
setupProxy();
But I still get the same error. Any ideas on what I might be doing wrong or how to properly set up a proxy with Puppeteer? Thanks in advance for any help!
i had similar prob before. try using env vars for proxy settings instead of hardcoding them. like this:
const browser = await puppeteer.launch({
args: [`--proxy-server=${process.env.PROXY_SERVER}`]
});
also make sure ur proxy actually works outside puppeteer. good luck!
I’ve encountered similar issues with Puppeteer and proxies before. One thing that helped me was double-checking the proxy configuration. Make sure your proxy is actually working by testing it outside of Puppeteer first.
Another approach that worked for me was using a third-party library like ‘puppeteer-extra-plugin-proxy’. It simplifies the process and handles authentication more reliably.
Also, try running Puppeteer in non-headless mode (which you’re already doing) and watch the browser. Sometimes you can spot visual cues about what’s going wrong.
Lastly, ensure your Puppeteer version is up-to-date. Older versions had some proxy-related bugs that have since been fixed. If all else fails, consider using a different proxy service - some just don’t play well with Puppeteer.
I’ve dealt with this issue before, and it can be frustrating. One solution that worked for me was to use a PAC (Proxy Auto-Configuration) file instead of directly specifying the proxy server. Here’s how you can try it:
Create a simple PAC file (e.g., proxy.pac) with your proxy details:
function FindProxyForURL(url, host) {
return 'PROXY proxyhost.example.com:8080; DIRECT';
}
Then modify your Puppeteer launch options:
const browser = await puppeteer.launch({
args: ['--proxy-pac-url=file:///path/to/your/proxy.pac']
});
This approach can sometimes bypass the ERR_NO_SUPPORTED_PROXIES error. Also, ensure your proxy supports HTTPS connections, as some websites might require it. If issues persist, try a different proxy service or consider using a VPN instead.