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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To capture a page your Windows development server is hosting, start the server, then use Puppeteer to open its full local URL and save a screenshot. Install Puppeteer in your Node.js project, run the script below, and replace port 3000 with the port your app actually uses.

Capture a localhost page with Puppeteer

Puppeteer’s documented workflow is to launch a browser, create a page, navigate to a URL, take a screenshot, and close the browser. The local server must already be running and reachable from the Node.js process. Include the URL scheme, such as http://, in the address passed to page.goto(). See the Page.goto API and the screenshot guide.

1. Install Puppeteer

In the project directory, install Puppeteer with npm:

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

npm install puppeteer

Puppeteer manages a compatible browser for its installed version. The documented system requirements and browser setup can change between releases, so check the requirements for the version installed in your project before choosing a Node.js or browser version.

#1 Best Overall

2. Start the local website

Run your application using its normal development command and leave the server running. Note the port and route it prints. For example, if it serves the home page at port 3000, the URL is http://localhost:3000/; if your app uses another port or route, use that instead.

3. Save this script as 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();
  }
})();

The HTTP status check is an optional safeguard: it turns a non-success response into a visible error instead of silently saving a screenshot of an error page. The finally block closes the browser even when navigation or capture fails.

4. Run it from the project directory

In PowerShell or Command Prompt, run:

node screenshot.js

With the relative output path above, Puppeteer writes localhost.png under the process’s current working directory—the directory from which you ran the command. This may not be the same as the folder containing the script.

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.
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.

Choose the right capture and wait behavior

Viewport or full page

fullPage defaults to false, which captures the current viewport. Set fullPage: true to request the full document. If you need only a region, use screenshot clipping; if you need a particular element, use the element’s screenshot method. See ScreenshotOptions and the screenshot guide.

Navigation completion is not always app readiness

waitUntil: 'networkidle2' is one documented navigation wait option, but pages with persistent network activity may not reach that state as expected. Choose a wait condition that fits the app. If a specific component must render before capture, wait for its selector or another app-specific condition before calling screenshot().

Write a file or keep the image in memory

Providing path saves the screenshot to disk. Without a path, page.screenshot() returns screenshot data as a Uint8Array; your code can pass those bytes to another operation rather than writing a file. See the Page.screenshot API and ScreenshotOptions.

Rank #3
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.

Use the browser supported by your Puppeteer version

Puppeteer is guaranteed to work with its bundled browser. You can select an installed Chrome channel or set an executablePath, but a system-installed browser is not as strongly supported and may have compatibility issues. Unless you have a reason to use a separate Chrome installation, start with Puppeteer’s managed browser. The LaunchOptions documentation explains browser selection.

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

The Puppeteer 25.12.0 system requirements surfaced in the documentation list Node 22.12+ and Chrome for Testing on Windows x64. Treat those as requirements for that documented release, not a promise that every installed Puppeteer version has identical requirements. Check the current system requirements for your version. Puppeteer’s browser management docs show npx @puppeteer/browsers install chrome@stable for installing Chrome for Testing: browser management.

Troubleshoot common Windows problems

  • Navigation fails or the screenshot is an error page: Confirm the development server is still running, the port and route are correct, and the URL includes http:// or https://. Check the response status and the server’s terminal output.
  • The screenshot is missing: Confirm that path is set and look in the process’s current working directory. Use an absolute path if you want the output location to be unambiguous. Puppeteer’s ScreenshotOptions documents path behavior.
  • The image is captured before content appears: Wait for the navigation condition or an app-specific selector that indicates the page is ready. Network-idle waiting may be unsuitable for a page that keeps requests open.
  • Puppeteer cannot find its browser: Check the browser cache and configured installation location. Puppeteer’s troubleshooting guidance documents PUPPETEER_CACHE_DIR for changing the cache directory: Troubleshooting.
  • Chrome launch is blocked by policy: Puppeteer disables extensions by default. Some managed Chrome policies that enforce extensions can prevent launch; the troubleshooting guide describes enableExtensions as a workaround. Use it only if that policy is the actual cause.
  • Permission or user-data-directory error: Puppeteer needs access to its browser files and a writable user-data directory. The troubleshooting guide notes that, starting with Puppeteer v22.14.0, Puppeteer attempts to configure permissions on downloaded Chrome files using Chrome’s setup.exe. For older versions or persistent problems, follow the version-specific guidance rather than changing permissions broadly. If the profile directory is the problem, the guide documents setting userDataDir.
  • A custom Chrome executable will not launch: Verify that the executable path exists and is compatible with your Puppeteer version. The bundled browser is the supported starting point; a custom system browser carries compatibility risk.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot of a publicly reachable page rather than a page available only on your machine, ScreenshotNeo can return an image or PDF from one GET request. It is not a way to capture a localhost-only address: the service must be able to reach the target URL.

Rank #4
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • 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.

For example, this cURL request saves a WebP screenshot of a public page. Replace YOUR_API_KEY with your key and change the target URL as needed. See the ScreenshotNeo API documentation for options.

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

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.

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

Frequently Asked Questions

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

Yes, provided the local web server and the browser Puppeteer launches can reach the page on your machine. The target does not need to be a public website.

Why does localhost work in my browser but not in Puppeteer?

Puppeteer may be using a different port or route, the server may have stopped, or the script may be running in a different environment that cannot reach that localhost address. Check the exact URL from the server output and run the script on the same machine as the server.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$245.99
Bestseller No. 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)
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.
$285.00

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.