zfcsoftware / puppeteer-real-browser

This package is designed to bypass puppeteer's bot-detecting captchas such as Cloudflare. It acts like a real browser and can be managed with puppeteer.
https://www.npmjs.com/package/puppeteer-real-browser
MIT License
622 stars 84 forks source link

ERR_CONNECTION_REFUSED Cloudflare #146

Closed rtritto closed 1 month ago

rtritto commented 1 month ago

Using an URL site with Cloudflare.

Code

import { connect } from 'puppeteer-real-browser'

const { page } = await connect({})

await page.goto('<URL>')

Output


C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\puppeteer-core-patch-npm-1.0.1-95fd1d1f38-10c0.zip\node_modules\puppeteer-core-patch\src\cdp\Frame.ts:216
          ? new Error(`${response.errorText} at ${url}`)
            ^

Error: net::ERR_CONNECTION_REFUSED at <URL>
    at navigate (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\puppeteer-core-patch-npm-1.0.1-95fd1d1f38-10c0.zip\node_modules\puppeteer-core-patch\src\cdp\Frame.ts:216:13)       
    at Function.race (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\puppeteer-core-patch-npm-1.0.1-95fd1d1f38-10c0.zip\node_modules\puppeteer-core-patch\src\util\Deferred.ts:49:14)
    at CdpFrame.goto (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\puppeteer-core-patch-npm-1.0.1-95fd1d1f38-10c0.zip\node_modules\puppeteer-core-patch\src\cdp\Frame.ts:169:17)  
    at CdpPage.goto (C:\Users\<USER>\AppData\Local\Yarn\Berry\cache\puppeteer-core-patch-npm-1.0.1-95fd1d1f38-10c0.zip\node_modules\puppeteer-core-patch\lib\esm\puppeteer\api\Page.js:561:20)
    at <anonymous> (C:\<PROJECT>\start.ts:15:1)

Info

puppeteer-real-browser: 1.3.3 OS: Windows

Workaround

Add a delay of 5 seconds before goto (the error appear with lower seconds)

import { setTimeout } from 'node:timers/promises'
...
// Add delay of 5 seconds
await setTimeout(5000)
await page.goto('<URL>')
zfcsoftware commented 1 month ago

It has been tested many times with the test file and there are no issues with Cloudflare WAF and Turnstile. There may be a momentary problem with the proxy you are using or your network. If the issue can be reproduced, please report it via this thread. Thank you.

https://github.com/user-attachments/assets/8b604a5b-d5cd-40aa-a42a-930983a14d62