DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › Chrome for Testing

Capture a Website Screenshot in Node.js with Puppeteer on an Ubuntu VPS in India

By Freedom251 Team · · 7 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a website screenshot with Puppeteer on an Ubuntu VPS, install a supported Node.js version and Puppeteer’s compatible Chrome for Testing browser, confirm Chrome’s Linux dependencies and sandbox work, then navigate to the page and call page.screenshot(). Puppeteer’s current system-requirements documentation lists Node.js 22.12 or later and Debian/Ubuntu Linux on x64 or arm64; check the requirements again when deploying because they can change. The reviewed Puppeteer documentation does not specify a different installation path for India; the VPS location can affect a site’s location-dependent content, so capture from the actual server where the result will be used.

Install Puppeteer and its browser on Ubuntu

This guide assumes you can SSH into an Ubuntu VPS and run commands as a user that will also run the screenshot script. Puppeteer runs headless by default, so a desktop environment is not required.

As an Amazon Associate I earn from qualifying purchases.

Check Node.js and architecture

Check the installed runtime and machine architecture:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
node --version
npm --version
dpkg --print-architecture

The Puppeteer project’s current system requirements list Node.js 22.12 or later and Chrome for Testing support on Debian/Ubuntu Linux x64 and arm64. If the VPS is not x64 or arm64, do not assume this browser-download workflow is supported; consult the requirements for the current compatibility information.

Install the package and compatible Chrome

In a new project directory, initialize npm and install puppeteer:

mkdir site-screenshot
cd site-screenshot
npm init -y
npm install puppeteer

The puppeteer package downloads a compatible Chrome for Testing browser by default. Package managers or deployment environments that block install scripts may skip that download. If so, allow the Puppeteer install script or install the browser explicitly with the documented command:

npx puppeteer browsers install

Use Puppeteer’s installation guide for current installation details. Keep the browser cache accessible to the same operating-system user that runs the script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the package that matches browser ownership

  • puppeteer is the straightforward choice when Puppeteer should download and manage its compatible browser.
  • puppeteer-core does not download Chrome. Use it when you manage a preinstalled or remote browser yourself, and configure the executable path or browser channel as appropriate.

Capture a full-page screenshot with Node.js

Save this as screenshot.mjs in the project directory. It navigates to the page, waits for the example readiness condition, writes a full-page PNG, and closes Chrome even if navigation or capture fails.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'screenshot.png', fullPage: true });
} finally {
  await browser.close();
}

Run it with:

node screenshot.mjs

The output path is relative to the process’s working directory. Use an absolute path if a service manager, cron job, or container may start the script from a different directory. The official screenshot guide demonstrates Page.screenshot(); fullPage: true requests a capture of the full page rather than only the viewport.

Choose a readiness condition that fits the site

waitUntil: 'networkidle2' is the condition used in Puppeteer’s example, not a guarantee that every modern application has finished rendering. Sites that poll continuously may never become idle, while a page can become idle before delayed or lazy content appears. For a page with a known rendered landmark, wait for that selector before taking the screenshot:

await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.waitForSelector('main article');
await page.screenshot({ path: 'screenshot.png', fullPage: true });

Replace main article with a selector that appears only when the content you need is ready. For lazy-loaded images, consider scrolling through the page or otherwise triggering the site’s loading behavior before capture; then verify the resulting image. No single wait condition guarantees correct rendering on every site.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture one element instead of the whole page

Use ElementHandle.screenshot() when you need a specific component rather than the page:

const element = await page.waitForSelector('.pricing-card');
if (!element) throw new Error('Pricing card was not found');
await element.screenshot({ path: 'pricing-card.png' });

Use a selector that identifies the intended element, and wait for it after navigation. See the ElementHandle screenshot API for the method’s current details.

Make the capture match the intended result

  • Viewport: set the viewport before navigation if the target is responsive; the page may lay out differently at mobile and desktop widths.
  • Full page or viewport: use fullPage: true for a long page, or omit it when only the visible viewport is wanted.
  • Location-dependent content: a VPS in India may receive different content from a server elsewhere because of the site’s own location, account, or network rules. Test from the VPS and state any locale or timezone assumptions in downstream use.
  • Output and permissions: ensure the process can write to the chosen output directory and that the service user has access to Puppeteer’s browser cache.

Keep Chrome launch secure on a VPS

Do not add --no-sandbox as a routine fix. Puppeteer’s troubleshooting guidance strongly discourages running Chrome without its sandbox because the sandbox helps protect the host from untrusted web content.

If Chrome reports “No usable sandbox!” on Ubuntu 23.10 or later, investigate the documented AppArmor interaction that can prevent user namespaces for Puppeteer-downloaded Chrome for Testing in the described environment. Check host policy and configuration rather than assuming every Ubuntu VPS has the same cause. Also confirm the browser is running under the expected account and that the host supports the required sandbox features. See the Puppeteer troubleshooting guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common VPS failures

Symptom Likely cause What to check or do
Could not find Chrome The package install script did not run, the browser was not downloaded, or the runtime user cannot access its browser cache. Run npx puppeteer browsers install; check whether install scripts were blocked and ensure the service user can access the installed browser and cache.
Chrome exits immediately or reports missing shared libraries A minimal VPS image may lack required system libraries, or the browser architecture may be unsupported. Confirm the architecture against the current system requirements, then use Puppeteer’s troubleshooting dependency list. Inspect the reported missing libraries instead of guessing at packages.
No usable sandbox! Sandbox support or host policy may be preventing Chrome from starting; Ubuntu 23.10+ AppArmor behavior is one documented possibility for the described Chrome for Testing setup. Keep the sandbox enabled and diagnose the host configuration and AppArmor conditions using the troubleshooting documentation. Disabling the sandbox is a security-compromising fallback, not the default fix.
The screenshot is blank or misses content Navigation completed, but application rendering, delayed content, or lazy loading did not. Wait for a page-specific selector or condition, trigger lazy loading if needed, and verify the capture. Do not treat network idle as proof that every site is fully rendered.
Works in SSH but fails under cron or a service The scheduled process may use another working directory, operating-system user, environment, or browser-cache location. Use an explicit output path, run with the intended service account, and confirm that account can find the browser and write the output file.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

Each capture launches or uses a real browser, so account for Chrome startup, page loading, and the memory and CPU required by the target site when sizing a VPS or scheduling concurrent work. The reviewed Puppeteer documentation does not establish a universal resource minimum or capture-time guarantee; profile your own pages and concurrency on the intended server.

For repeatable results, pin project dependencies in your lockfile, keep the Puppeteer package and its compatible browser installation aligned, and test after upgrades. A screenshot is a snapshot of the page state observed by that browser at that time; site changes, location-sensitive responses, consent banners, or delayed content can change the output. In India, there is no special Puppeteer install path established by the cited documentation, but the actual VPS network location can affect what the target serves.

Or skip the browser setup

If you only need an image or PDF and do not want to maintain Chrome on the VPS, ScreenshotNeo is a website screenshot API and MCP server. A single GET request returns an image or PDF. The Node.js example below saves the returned bytes as a WebP file; replace the URL and provide your API key.

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Sign up free for 1,000 screenshots a month, with no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Puppeteer need a desktop environment on an Ubuntu VPS?

No. Puppeteer runs headless by default, so a desktop environment is not needed for the documented screenshot workflow.

Can I run this on an India-based VPS?

The reviewed Puppeteer documentation does not define a separate India installation path. Check the server’s architecture and runtime requirements; the server’s location may affect the content a website serves.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Chrome for TestingNode.jsPuppeteerUbuntuVPSwebsite screenshots

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.