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 bought a proxy from a service called Froxy. I’m using their example code:

import puppeteer from 'puppeteer';

async function runBrowser() {
  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');
}

runBrowser();

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

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

I’m scratching my head here. Any ideas what might be causing this? Where should I start looking to fix it? Thanks for any help!

I’ve encountered similar issues with Puppeteer and proxies on Debian systems. First, ensure your Debian firewall isn’t blocking the proxy connection. Check iptables rules and temporarily disable the firewall to test.

Next, verify DNS resolution for the proxy domain. Try using an IP address instead of the hostname in your proxy settings. Also, check if your Debian system has the necessary CA certificates installed for secure connections.

If those don’t work, try adding ‘–ignore-certificate-errors’ to your Puppeteer args. This isn’t ideal for production, but can help isolate the issue.

Lastly, consider using a different proxy service or trying a SOCKS proxy instead of HTTP. Sometimes certain proxy protocols work better with specific network configurations.

I’ve been in your shoes before, and it can be frustrating when something works on one system but not another.

First, make sure you have the latest version of Puppeteer installed. I once spent hours debugging only to realize I was using an outdated version with known issues.

Have you tried using a different proxy service? I’ve had success with Brightdata (formerly Luminati) on Debian systems. They provide detailed setup instructions which might help pinpoint where your current setup is falling short.

Also, check your system’s proxy settings. Sometimes, global proxy settings can interfere with Puppeteer’s configuration. You might need to explicitly set NO_PROXY for localhost if you’re running into this.

Lastly, if all else fails, consider using a Docker container for your Puppeteer scripts. This can help isolate the environment and rule out system-specific issues. It’s saved me more than once when dealing with finicky setups.