Halloween 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 ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › localhost

How to Take a Puppeteer Screenshot of a Localhost Page on Windows

By Freedom251 Team · · 5 min read

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

Start your Windows development server, then use Puppeteer to open its full local URL and save a screenshot. The example below captures the full page at http://localhost:3000; replace the port and route with the ones your app serves.

Run Puppeteer against your local site

In your Node.js project, install Puppeteer, start the app’s development server, and run a script that launches its managed browser, navigates to the local page, and saves an image. Puppeteer’s screenshot guide documents the launch, navigation, capture, and close flow; Page.goto() requires a URL with a scheme such as http://.

As an Amazon Associate I earn from qualifying purchases.

  1. In a terminal opened in the project directory, install Puppeteer if it is not already a dependency: npm install puppeteer.
  2. Start the web app using its normal development command, for example npm run dev. Leave that process running and note the local address and port it prints.
  3. Create screenshot.js in the project directory and use the code below, substituting your app’s URL.
  4. Open a second terminal in that directory and run node screenshot.js.
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    const response = await page.goto('http://localhost:3000', {
      waitUntil: 'networkidle2',
    });

    if (response && !response.ok()) {
      throw new Error(`Local page returned HTTP ${response.status()}`);
    }

    await page.screenshot({ path: 'localhost.png', fullPage: true });
  } finally {
    await browser.close();
  }
})();

A successful run writes localhost.png in the process’s current working directory. The HTTP status check is an additional safeguard, not a Puppeteer requirement. The finally block closes the browser even if navigation or capture fails.

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

Choose what to capture and where the result goes

Viewport or full page

By default, page.screenshot() captures the current viewport. Set fullPage: true to request a capture of the full document. To capture just part of the page, use the screenshot API’s clipping options or capture an element; see ScreenshotOptions.

#1 Best Overall

Save a file or use image bytes

Providing path writes the screenshot to disk. Without a path, the screenshot data is returned as a Uint8Array, which can be passed to another part of your Node program instead. A relative path such as localhost.png is resolved from the process’s current working directory, which may not be the same as the folder containing the script.

Wait for the page you need

The example uses waitUntil: 'networkidle2', an option shown in Puppeteer’s screenshot guide. Pages with persistent requests, such as live updates or analytics, may not reach that state in a useful time. Choose a wait condition suited to the page, or wait for an app-specific selector or other condition before calling screenshot(). A navigation event alone does not guarantee that every client-rendered component or image has finished appearing.

Windows and Puppeteer version requirements

Requirements vary by Puppeteer release. The official system requirements surfaced for Puppeteer 25.12.0 list Node.js 22.12 or later and Chrome for Testing on Windows x64. Check the system requirements for the version installed in your project rather than assuming those values apply to every release. In the documented setup, Windows can unpack Chrome for Testing with tar.exe or PowerShell.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Puppeteer manages a browser build intended to work with the installed Puppeteer version. Its browser management guidance shows npx @puppeteer/browsers install chrome@stable for installing Chrome for Testing. Use the browser managed for your installed Puppeteer version when possible; selecting system Chrome or another executable is supported, but compatibility is not guaranteed to the same degree.

When to use another browser executable

If a project must launch an installed Chrome channel or a specific browser executable, set Puppeteer’s launch options accordingly. The LaunchOptions API documents channel selection and executablePath. Puppeteer cautions that it is guaranteed to work with its bundled browser, so a system-browser choice can introduce version compatibility issues.

Windows troubleshooting

Navigation fails or the page cannot be reached

  • Confirm the development server is still running and that the URL uses the right port and route.
  • Include the scheme: use http://localhost:3000, not just localhost:3000.
  • Open the same URL in a regular browser on the Windows machine. If it does not load there, resolve the app or server issue before debugging Puppeteer.
  • If the request completes with an HTTP error, the example’s status check reports the returned status; check the app’s route and server logs.

Puppeteer cannot find or launch Chrome

  • Use the browser installation and cache configuration for the Puppeteer version in the project. The troubleshooting guide describes the browser cache location and the PUPPETEER_CACHE_DIR setting when the browser cannot be found.
  • For an explicit system Chrome path, configure executablePath and account for the compatibility caveat described above.
  • On managed Windows devices, organizational Chrome policies that enforce extensions can conflict with Puppeteer’s default --disable-extensions argument. The troubleshooting guide describes enableExtensions as a workaround where appropriate.
  • If launch reports permission errors, follow the guidance for the installed version and environment. Puppeteer says that beginning with v22.14.0 it attempts to configure permissions on downloaded Chrome files through Chrome’s setup.exe; older versions or persistent errors may require manual permission changes as documented there. Do not broadly weaken permissions without a specific need.
  • If the browser cannot write its profile, configure a writable userDataDir as described in the troubleshooting guide.

The screenshot is missing

Check that the path option is present and look in the process’s working directory, not necessarily the script’s directory. Use an absolute path if you want the output location to be unambiguous.

Rank #3
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage | LPDDR4 RAM, 180° Lay-Flat, Dual-Band WiFi, Type-C PD Fast Charging, Thin & Lightweight for Students, Home & Office, Gray
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.

The screenshot is incomplete or blank

Verify the page is rendering the content before capture. If navigation succeeds but a client-rendered section is missing, wait for a selector or application-specific condition. If networkidle2 waits too long because the page keeps making requests, choose a more appropriate wait strategy and explicitly wait for the content you need.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo can return a screenshot or PDF from one GET request, without installing and managing a local browser. See the ScreenshotNeo website and its API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Replace the example URL with the page you want to capture and use your API key. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for free.

Frequently Asked Questions

Can Puppeteer take a screenshot of a localhost page without an internet connection?

Yes, if the local web server is reachable by the Node.js process; the page itself does not need to be publicly hosted.

Does Puppeteer save a screenshot as PNG by default?

Puppeteer’s screenshot API returns image data, and the file type is inferred from the path extension when saving. The example’s .png filename requests a PNG output.

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

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.

localhostNode.jsPuppeteerscreenshotsWindows

Leave a Reply

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

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.

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.