Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Get the Final URL After a Redirect in Puppeteer

Read the current redirected destination with page.url() after Puppeteer’s goto() resolves; use response.url() or redirectChain() for response details or redirect history.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After page.goto() resolves, call page.url() to get the page’s current URL. Use the returned response’s url() when you specifically need the URL associated with that navigation response; use redirectChain() to inspect the earlier redirected requests.

Get the current page URL after navigation

Page.goto() follows redirects and, when there are multiple, resolves with the response from the last redirect. Read the destination from the page after the navigation resolves:

As an Amazon Associate I earn from qualifying purchases.

const response = await page.goto('https://example.com');
const finalUrl = page.url();

console.log(finalUrl);

page.url() returns the page URL and is a shortcut for page.mainFrame().url(). It is the straightforward choice when you want to know where the browser page ended up. See the Puppeteer Page.url() API reference and Page.goto() API reference.

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

Choose the right URL API for your need

Current page destination: page.url()

Use this for the page’s URL after navigation, including when you care about its current state rather than only the response that completed goto().

Navigation response URL: response?.url()

goto() returns an HTTPResponse or null. If you need the URL attached to the response it returned, read that response’s URL:

const response = await page.goto('https://example.com');
const responseUrl = response?.url();

console.log(responseUrl);

Optional chaining avoids calling a method on a missing response. Puppeteer documents a null result for navigation to about:blank and for a same-URL navigation that changes only the hash. The response URL is provided by HTTPResponse.url().

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Earlier redirected requests: redirectChain()

For debugging, inspect the navigation response’s request chain. It lists requests that were redirected; it is history, not the final destination:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const response = await page.goto('http://example.com');
const redirects = response?.request().redirectChain() ?? [];
const finalUrl = page.url();

console.log('Redirected requests:', redirects.map(request => request.url()));
console.log('Final page URL:', finalUrl);

A single redirect from HTTP to HTTPS yields a chain containing the original HTTP request. With no redirects, the chain is empty. See HTTPRequest.redirectChain().

Check HTTP status separately

A completed navigation does not guarantee a successful HTTP status. Puppeteer notes that in headless shell, goto() does not throw for valid HTTP responses such as 404 or 500. If status matters, inspect it explicitly:

const response = await page.goto('https://example.com');
const finalUrl = page.url();
const status = response?.status();

console.log({ finalUrl, status });

An HTTP error response is different from a network or request failure: 404 and 503 are HTTP responses, not necessarily navigation exceptions. The Page.goto() reference documents navigation behavior, while HTTPRequest describes request handling.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Account for later client-side navigation

A page may change its URL through client-side navigation after the initial goto() has resolved. In that case, response.url() still identifies the response returned by the original navigation, while page.url() read later reflects the page’s current URL. If you need the post-navigation destination, wait for the relevant client-side navigation to finish before sampling page.url().

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

Common issues and fixes

  • Reading response.url() throws: goto() can return null for about:blank or same-URL hash navigation. Use response?.url() or read page.url().
  • The redirect chain appears empty: An empty chain means no redirected request was recorded. It does not mean the final URL is unavailable; read page.url().
  • The request completed but the site returned an error page: Check response?.status(); navigation completion and an HTTP success status are separate checks.
  • The logged response URL differs from the page URL: The page may have navigated client-side after the original response. Read page.url() after that later navigation completes.
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 your goal is to capture the redirected destination as an image, ScreenshotNeo accepts a URL in one GET request and returns a screenshot. The same request pattern can capture the starting URL without configuring Puppeteer; the service produces a screenshot rather than exposing Puppeteer’s redirect-chain data.

ScreenshotNeo API documentation

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
  • Cookie and consent banners, newsletter popups and chat widgets are removed before capture; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed. Responses say which page verdict applied and whether it was billed.
  • 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 free.

Frequently Asked Questions

Does Puppeteer return the final redirect response from page.goto()?

Yes. For multiple redirects, goto() resolves with the response from the last redirect.

Is redirectChain() the final URL?

No. It returns the requests that were redirected; use page.url() for the current destination.

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