Endless loop with Cloudflare's human verification in Puppeteer JS

Hey everyone, I’m having trouble with Puppeteer and Cloudflare’s ‘Are you human?’ captcha. The captcha keeps looping, even when I try to solve it by hand or use a bypass extension. It used to work fine before.

I think it might be related to proxy or captcha-solving extensions. I’ve had similar issues in regular Chrome after adding certain extensions.

I’ve tried:

  • Different browsers (Chrome, Chromium, Brave, Opera)
  • Custom user agents and headers
  • Clearing cache and cookies
  • Using puppeteer-extra and puppeteer-extra-plugin-stealth

Here’s a basic version of my code:

const puppeteerExtra = require('puppeteer-extra');
const Stealth = require('puppeteer-extra-plugin-stealth');

puppeteerExtra.use(Stealth());

async function runBrowser() {
  const browser = await puppeteerExtra.launch({
    headless: false,
    args: ['--proxy-server=myproxy.example.com:8080'],
  });

  const page = await browser.newPage();

  await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36');
  await page.setExtraHTTPHeaders({ 'Accept-Language': 'en-US,en;q=0.9' });

  await page.authenticate({ username: 'myuser', password: 'mypass' });

  await page.goto('https://example.com/login', { waitUntil: 'networkidle2', timeout: 0 });

  await page.type('#email', '[email protected]');
  await page.type('#pass', 'password123');
  await page.click('#login-button');

  await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 0 });
  await page.screenshot({ path: 'result.png' });
}

runBrowser();

The browser gets stuck on the Cloudflare page, looping endlessly. Any ideas on how to fix this?

I’ve encountered similar issues with Cloudflare’s human verification when using Puppeteer.

One approach that’s worked for me is implementing a delay between actions and randomizing user behavior patterns. Try adding random waits between page interactions and simulating mouse movements to mimic human-like behavior.

Additionally, consider using a residential proxy instead of a datacenter one since Cloudflare tends to flag the latter more frequently. Rotating your IP addresses regularly can also help.

Warming up your browser session by visiting some benign sites before accessing the target URL can establish a more natural browsing pattern. Lastly, avoid reusing browser contexts across sessions to prevent triggering Cloudflare’s defenses.

I’ve dealt with this Cloudflare headache before, and it’s a real pain. What worked for me was ditching the proxy altogether. I know it sounds counterintuitive, but sometimes less is more when it comes to bypassing these checks.

Another thing that helped was using a ‘normal’ browser profile. I set up Puppeteer to use my regular Chrome user data directory. This way, it looks like a legit browser with history, cookies, and all that stuff.

const browser = await puppeteer.launch({
  headless: false,
  userDataDir: '/path/to/your/chrome/user/data/directory'
});

This approach made a huge difference. The site treated my bot like a regular user, and I sailed right past Cloudflare. Just make sure you’re not logged into any important accounts when you do this!

yo man, i feel ur pain. cloudflare is a real b*tch sometimes. have u tried using a browser fingerprint randomizer? it worked wonders for me. also, try adding some random mouse movements and scrolls. makes it look more human-like. good luck bro!