Puppeteer proxy connection failing on Debian: Troubleshooting ERR_TUNNEL_CONNECTION_FAILED

I’m stuck with a problem using Puppeteer and a proxy on my Debian 12 setup. Here’s what’s going on:

I got a proxy from a company called froxy. They gave me some sample code to test it out:

import puppeteer from 'puppeteer';

async function testProxy() {
  const browser = await puppeteer.launch({
    headless: true,
    args: ['--no-sandbox', '--proxy-server=proxy.froxy.com:9000']
  });
  const page = await browser.newPage();
  await page.authenticate({
    username: 'myuser',
    password: 'mypass'
  });
  await page.goto('https://froxy.com/api/detect-ip');
}

testProxy();

This code works fine on my Windows machine. The browser starts up with the proxy no problem. But when I try to run it on Debian, I get this error:

Error: net::ERR_TUNNEL_CONNECTION_FAILED at https://froxy.com/api/detect-ip

I’m scratching my head here. Any ideas what could be causing this? Where should I start looking to fix it? Is there something specific to Debian that might be messing things up?

As someone who’s wrestled with Puppeteer on various Linux distros, I can say Debian can be finicky with proxies. Have you checked if the proxy service is actually reachable from your Debian machine? Try a simple curl command to test connectivity:

curl -v -x proxy.froxy.com:9000 https://froxy.com/api/detect-ip

If that fails, it might be a network issue rather than Puppeteer-specific. Also, ensure you have the latest ca-certificates package installed:

sudo apt update && sudo apt install ca-certificates

Sometimes, outdated certificates can cause these connection errors. If all else fails, you might want to try a different proxy provider or consider setting up a local proxy server like Squid to see if it’s a Debian-specific issue or something with the froxy service.

I’ve encountered similar issues on Debian systems before. One often overlooked aspect is the system’s proxy settings. Ensure that your system-wide proxy configuration aligns with the Puppeteer settings. You can check this by running ‘env | grep -i proxy’ in the terminal.

Another potential culprit could be SSL/TLS issues. Debian’s default security settings can sometimes interfere with proxy connections. Try adding ‘–ignore-certificate-errors’ to your Puppeteer launch args.

If these don’t work, consider running Puppeteer with verbose logging enabled to obtain more detailed error output, which may help in pinpointing the exact cause of the connection failure.

hey there, sounds like a classic proxy issue on linux. have u tried checking ur firewall settings? sometimes they can block proxy connections. also, double-check ur network config - DNS might be messed up. if all else fails, try a different proxy server or port. good luck!