October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Puppeteer goto() Options: How to Control Page Navigation

A practical guide to Puppeteer page.goto(): choose a readiness milestone, set timeouts and referrers, inspect responses, and troubleshoot navigation failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use page.goto(url, options) to choose when Puppeteer treats navigation as complete, how long it waits, whether the wait can be cancelled, and which referrer metadata to send. The key is to treat waitUntil as a browser lifecycle milestone—not proof that an application has finished rendering—and check the returned HTTP response when status matters.

What page.goto() does and returns

Page.goto(url, options?) navigates the page to a URL. Supply a URL with its scheme, such as https://example.com. The promise resolves to the main resource’s HTTPResponse; after redirects, that response represents the final destination. The API documentation identifies these behaviors for Puppeteer v25.12.0. Puppeteer Page.goto() reference

As an Amazon Associate I earn from qualifying purchases.

There are important exceptions: navigation to about:blank, and navigation to the same URL when only its hash changes, resolve successfully with null rather than an HTTP response. Account for that before calling response methods.

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.

A resolved navigation does not by itself mean the HTTP status is successful. Inspect response.status() or response.ok() if your workflow requires a successful status. In headless shell mode, for example, valid HTTP responses such as 404 and 500 do not make goto() throw. Puppeteer Page.goto() reference

Choose a navigation completion condition

The waitUntil option tells Puppeteer which browser lifecycle event or events must fire before the navigation wait is considered complete. Its default is 'load'. You can pass one event or an array; an array requires every listed event. Puppeteer WaitForOptions reference

These events describe browser loading milestones, not whether a single-page app has fetched its data, hydrated its interface, or made a particular control usable. Choose the earliest milestone that supports your next step, then wait for the actual UI condition your task needs.

  • 'load': the default; use it when the page’s load event is an appropriate boundary for the next operation.
  • 'domcontentloaded': use when the parsed document is enough to begin the next step and waiting for the full load event would be unnecessary.
  • 'networkidle0' or 'networkidle2': use only when the relevant network-idle condition suits the page. Applications with persistent network activity may not reach it.
  • An array, such as ['domcontentloaded', 'networkidle2']: use when both lifecycle events matter; Puppeteer waits for all events in the array.

For application readiness, wait for a selector or another app-specific condition after navigation. Puppeteer’s waitForSelector() can wait for an element to appear, with visibility controls when needed. The selector below is only an example; choose one that represents readiness on your target site. Puppeteer waitForSelector() reference

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

Set a timeout or cancel the wait

timeout is the maximum wait in milliseconds. In Puppeteer v25.12.0 its default is 30,000 milliseconds; 0 disables the timeout. Disabling it removes the time limit, so a stalled navigation can wait indefinitely unless another mechanism ends it. Puppeteer WaitForOptions reference

Set the limit per navigation when a particular destination needs a different budget. For a shared default, use page.setDefaultNavigationTimeout(); it applies to goto(), goBack(), goForward(), reload(), setContent(), and waitForNavigation(). page.setDefaultTimeout() also changes the default timeout used by page operations. Puppeteer setDefaultNavigationTimeout() reference

Pass an AbortSignal as signal when the caller needs to cancel the navigation wait, for example when a larger operation is cancelled. Puppeteer WaitForOptions reference

Set referrer metadata for one navigation

GoToOptions accepts referer and referrerPolicy. A referer supplied to goto() takes precedence over the Referer header set with page.setExtraHTTPHeaders(); referrerPolicy similarly takes precedence over a referrer-policy header. Use these per-navigation fields when the navigation needs values different from the page-wide extra headers. Puppeteer GoToOptions reference

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

Runnable navigation example

This JavaScript example navigates once, rejects a non-success HTTP response when one exists, and then waits for a visible application element. It assumes page is an initialized Puppeteer Page.

const response = await page.goto('https://example.com', {
  waitUntil: 'domcontentloaded',
  timeout: 15_000,
});

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

await page.waitForSelector('main article', { visible: true });

The null check matters for cases such as about:blank or same-URL hash-only navigation. The selector must match the target application’s actual ready state; a lifecycle event alone cannot establish that.

Wait before clicking when a click triggers navigation

Start waiting for navigation before clicking. If the click happens first, the navigation can begin before the wait is listening.

const [response] = await Promise.all([
  page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
  page.click('a.next'),
]);

This coordination pattern is documented in the Page reference. Puppeteer Page reference

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

Common navigation failures and fixes

The Frame navigation reference documents rejection for these failure cases. Diagnose the cause rather than treating every rejection as an HTTP error: an HTTP 404 or 500 can still produce a response. Puppeteer Frame.goto() reference

  • Navigation timeout: the chosen lifecycle condition did not occur before the time limit. Confirm the site is reachable, choose a completion condition suited to the task, or adjust the per-call or navigation default timeout. Do not set timeout: 0 unless an unlimited wait is intentional.
  • SSL or certificate error: the connection’s certificate validation failed, including cases such as a self-signed certificate. Check the target’s certificate and the environment’s trust configuration.
  • Invalid target URL: validate the URL and include its scheme, such as https://.
  • Remote server unreachable or not responding: check the hostname, network access, and server availability before changing the wait condition.
  • Main resource load failure: the document request failed. Check the destination and any network or browser restrictions affecting the request.
  • URL rejected by an allowlist or blocklist: check the navigation policy configured for the environment and permit the intended destination if appropriate.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Mode-specific PDF caveat

The Page reference says headless shell does not support navigation to PDF documents. This restriction is specific to headless shell and should not be generalized to every Puppeteer or browser mode. Puppeteer Page.goto() reference

Or skip the browser setup

If your goal is a screenshot rather than browser automation, ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return an image or PDF without writing Puppeteer navigation and capture code. The endpoint and parameter details are in the ScreenshotNeo 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
  • Cookie banners are accepted before capture; known consent platforms, newsletter popups, and chat widgets are removed. Each step can be turned off.
  • Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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

Frequently Asked Questions

Can page.goto() resolve without returning an HTTP response?

Yes. It resolves with null for about:blank and same-URL navigation that changes only the hash.

Do multiple waitUntil events mean Puppeteer waits for any one of them?

No. When you pass an array, every listed lifecycle event must fire.

Does a successful goto() prove that the page returned HTTP 200?

No. Check the returned response status; a resolved navigation can have a non-success HTTP status.

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.

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

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.