Websites are no longer fooled by simple bots. Cloudflare, advanced anti-spam systems, and clever detection scripts are catching automated traffic every day. If Puppeteer isn't tuned right, you'll face bans, captchas, and endless blocks. Frustrating? Absolutely. But it doesn't have to be that way.
Puppeteer Stealth is your secret weapon. It disguises your bot as a real user — masking fingerprints, simulating mouse movements, and wiping automation traces clean. This guide will take you step-by-step through setting up Puppeteer Stealth so your scraping scripts glide past defenses like a pro.
Setting up Stealth mode is easier than you think. Just a few commands, a little configuration, and you're good to go.
Run this in your terminal:
npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
Here's what each package does:
puppeteer
: Controls Chrome or Chromium.
puppeteer-extra
: Framework to add plugins.
puppeteer-extra-plugin-stealth
: The magic layer that hides automation signs.
By default, Puppeteer reveals itself—headers say HeadlessChrome
, and detectable automation flags remain. Stealth mode flips the script.
Next, create an index.js
file with this:
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
(async () => {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://bot.sannysoft.com/');
await page.screenshot({ path: 'result.png' });
console.log('Test complete. Screenshot saved.');
await browser.close();
})();
Run it, then check result.png
. The site will show how well your bot is disguised.
Stealth mode is great, but you can push it further. Adjust the launch options to improve performance and dodge common server defenses:
const browser = await puppeteer.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--disable-gpu'
]
});
Why these? They cut unnecessary overhead and avoid conflicts that might trigger suspicion.
Before you hit production, verify your setup on these trusted sites:
bot.sannysoft.com
— Detects bots by behavior.
whatismybrowser.com
— Reveals your browser fingerprint.
httpbin.org/headers
— Shows HTTP headers sent with requests.
Run your bot, grab screenshots, analyze results. If you spot automation flags, tweak your settings.
One IP address? It's a dead giveaway. Proxies rotate your origin, spreading requests across many IPs. This drastically reduces bans.
Choose your proxy type carefully:
Server proxies: Fast, stable, great for bulk scraping.
Mobile proxies: Use real mobile IPs, harder to detect.
Plug in proxies using Puppeteer's launch args:
const browser = await puppeteer.launch({
headless: true,
args: ['--proxy-server=http://username:password@proxy_address:port']
});
Replace with your proxy details. Simple.
Static proxies get flagged fast. Rotate them on every request.
Here's a snippet for random proxy rotation:
const proxyList = [
'http://user1:pass1@proxy1:port',
'http://user2:pass2@proxy2:port',
'http://user3:pass3@proxy3:port'
];
const getRandomProxy = () => proxyList[Math.floor(Math.random() * proxyList.length)];
(async () => {
for (let i = 0; i < 5; i++) {
const proxy = getRandomProxy();
const browser = await puppeteer.launch({
headless: true,
args: [\`--proxy-server=${proxy}\`]
});
const page = await browser.newPage();
await page.goto('https://httpbin.org/ip');
console.log(\`Request via proxy: ${proxy}\`);
await browser.close();
}
})();
Each run uses a different IP, spreading your traffic footprint.
Before scaling up:
Test each proxy with multiple page loads.
Check latency—slow proxies kill efficiency.
Match proxy location to your target data region.
For example, if scraping US-only content, use US proxies.
No setup is perfect out of the box. Test often. Use the sites above to confirm your bot passes as human.
If you get blocked or flagged:
Review browser fingerprints.
Check headers carefully.
Adjust stealth plugin settings or add more browser mimicry.
Configuring Puppeteer Stealth isn't magic, but it's close. With the right plugins, smart proxies, and thorough testing, your bot can move through defenses undetected. This lets your scripts run uninterrupted, collecting data with confidence.
Websites are no longer fooled by simple bots. Cloudflare, advanced anti-spam systems, and clever detection scripts are catching automated traffic every day. If Puppeteer isn't tuned right, you'll face bans, captchas, and endless blocks. Frustrating? Absolutely. But it doesn't have to be that way.
Puppeteer Stealth is your secret weapon. It disguises your bot as a real user — masking fingerprints, simulating mouse movements, and wiping automation traces clean. This guide will take you step-by-step through setting up Puppeteer Stealth so your scraping scripts glide past defenses like a pro.
Setting up Stealth mode is easier than you think. Just a few commands, a little configuration, and you're good to go.
Run this in your terminal:
npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
Here's what each package does:
puppeteer
: Controls Chrome or Chromium.
puppeteer-extra
: Framework to add plugins.
puppeteer-extra-plugin-stealth
: The magic layer that hides automation signs.
By default, Puppeteer reveals itself—headers say HeadlessChrome
, and detectable automation flags remain. Stealth mode flips the script.
Next, create an index.js
file with this:
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
(async () => {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://bot.sannysoft.com/');
await page.screenshot({ path: 'result.png' });
console.log('Test complete. Screenshot saved.');
await browser.close();
})();
Run it, then check result.png
. The site will show how well your bot is disguised.
Stealth mode is great, but you can push it further. Adjust the launch options to improve performance and dodge common server defenses:
const browser = await puppeteer.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--disable-gpu'
]
});
Why these? They cut unnecessary overhead and avoid conflicts that might trigger suspicion.
Before you hit production, verify your setup on these trusted sites:
bot.sannysoft.com
— Detects bots by behavior.
whatismybrowser.com
— Reveals your browser fingerprint.
httpbin.org/headers
— Shows HTTP headers sent with requests.
Run your bot, grab screenshots, analyze results. If you spot automation flags, tweak your settings.
One IP address? It's a dead giveaway. Proxies rotate your origin, spreading requests across many IPs. This drastically reduces bans.
Choose your proxy type carefully:
Server proxies: Fast, stable, great for bulk scraping.
Mobile proxies: Use real mobile IPs, harder to detect.
Plug in proxies using Puppeteer's launch args:
const browser = await puppeteer.launch({
headless: true,
args: ['--proxy-server=http://username:password@proxy_address:port']
});
Replace with your proxy details. Simple.
Static proxies get flagged fast. Rotate them on every request.
Here's a snippet for random proxy rotation:
const proxyList = [
'http://user1:pass1@proxy1:port',
'http://user2:pass2@proxy2:port',
'http://user3:pass3@proxy3:port'
];
const getRandomProxy = () => proxyList[Math.floor(Math.random() * proxyList.length)];
(async () => {
for (let i = 0; i < 5; i++) {
const proxy = getRandomProxy();
const browser = await puppeteer.launch({
headless: true,
args: [\`--proxy-server=${proxy}\`]
});
const page = await browser.newPage();
await page.goto('https://httpbin.org/ip');
console.log(\`Request via proxy: ${proxy}\`);
await browser.close();
}
})();
Each run uses a different IP, spreading your traffic footprint.
Before scaling up:
Test each proxy with multiple page loads.
Check latency—slow proxies kill efficiency.
Match proxy location to your target data region.
For example, if scraping US-only content, use US proxies.
No setup is perfect out of the box. Test often. Use the sites above to confirm your bot passes as human.
If you get blocked or flagged:
Review browser fingerprints.
Check headers carefully.
Adjust stealth plugin settings or add more browser mimicry.
Configuring Puppeteer Stealth isn't magic, but it's close. With the right plugins, smart proxies, and thorough testing, your bot can move through defenses undetected. This lets your scripts run uninterrupted, collecting data with confidence.