October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Trace Redirects in Puppeteer

Learn how to inspect Puppeteer redirect chains after navigation, log network events, and diagnose common cases such as null responses and HTTP error statuses.

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.

After navigating with page.goto(), call response.request().redirectChain() to get the earlier requests in that resource’s redirect chain. The final navigation response is not a list of every hop, and page.goto() can return null for special navigations such as about:blank or a same-URL navigation that changes only the hash.

Get the redirect chain after navigation

Puppeteer’s HTTPRequest.redirectChain() returns the requests that preceded the current request in the same resource chain. With no redirect, it returns an empty array. For example, an HTTP-to-HTTPS redirect includes the original HTTP request.

As an Amazon Associate I earn from qualifying purchases.

const response = await page.goto('http://example.com');

if (response) {
  const chain = response.request().redirectChain();
  console.log('Redirect count:', chain.length);
  console.log('Earlier request URLs:', chain.map(request => request.url()));
}

Check for a null response before calling request(). When there is a response, the chain contains the earlier requests; the response returned by page.goto() corresponds to the last redirect response. The chain lists predecessor requests, so inspect the final response URL separately if you need the destination.

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

These APIs are documented in Puppeteer 25.12.0 documentation; the standalone redirectChain() page identifies version 25.10.0. Documentation labels can change, so check the API reference corresponding to the version installed in your project: redirectChain(), page.goto().

Log redirects and other network activity as it happens

Use page events when you need to see requests and responses as navigation proceeds, rather than only examining the chain after goto() resolves. Puppeteer listens for requests and responses by default; adding event handlers makes the activity visible in your own logs.

page.on('request', request => {
  console.log('request', request.method(), request.url());
});
page.on('response', response => {
  console.log('response', response.status(), response.url());
});
page.on('requestfailed', request => {
  console.log('failed', request.url(), request.failure()?.errorText);
});

const response = await page.goto(url);
if (response) {
  const chain = response.request().redirectChain();
  console.log('redirects', chain.map(request => request.url()));
}

A page issues requests for its document and many other resources. If you only want top-level navigation, filter request events with request.isNavigationRequest(); otherwise, unrelated images, scripts, and other resource requests can make the log noisy.

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

A redirect is not inherently a failed request: the redirect response completes the current request, then the browser issues another request. Puppeteer emits requestfinished for a completed request, including a redirecting one. A requestfailed event indicates a request failure such as a timeout, not merely an HTTP error status.

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

Distinguish HTTP error statuses from request failures

An HTTP 404 or 503 is still a completed HTTP exchange. It does not, by itself, trigger requestfailed. Check the response status to detect an unsuccessful HTTP result, and use requestfailed to diagnose transport or loading failures.

page.on('response', response => {
  if (response.request().isNavigationRequest()) {
    console.log('navigation status', response.status(), response.url());
  }
});

page.on('requestfailed', request => {
  console.error('request failed', request.url(), request.failure()?.errorText);
});

The Puppeteer network logging guide documents request and response listeners. Event and request behavior is covered in the HTTPRequest API.

Verify a redirect visually in Chrome DevTools

For a manual cross-check, open Chrome DevTools’ Network panel before navigating so it records the requests. Review the request table’s status and initiator information; the initiator type can identify a redirect and show how one request led to another. This is useful for a visual investigation, while redirectChain() is the direct way to obtain predecessor URLs in code.

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

See Chrome’s Network panel documentation for its request table and initiator details.

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

When the higher-level API is not enough

Puppeteer’s CDPSession can send Chrome DevTools Protocol commands and receive protocol events. Use it when you have a specific need that the request chain and page events do not cover; for ordinary redirect tracing, the higher-level APIs are simpler. Puppeteer warns that direct access to an HTTPRequest’s client can break Puppeteer, so avoid relying on that internal access for routine logging. See the CDPSession API.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot missing or confusing redirect data

  • response is null: Do not call response.request(). Puppeteer documents null responses for navigation to about:blank and same-URL navigation that changes only the hash.
  • The chain is empty: That means there were no preceding requests in that resource chain. Confirm that the navigation URL actually redirects; if it does not, an empty array is expected.
  • You see only the destination in the result: The response from page.goto() is for the last redirect response. Call response.request().redirectChain() to inspect preceding requests.
  • The log contains many URLs: Page events include subresources as well as navigation. Filter on request.isNavigationRequest() when you only need requests driving frame navigation.
  • A 404 or 503 is logged as a response, not a failure: That is expected. Inspect response.status() for HTTP status; reserve requestfailed for failures such as timeouts.
  • No request appears in DevTools: The Network panel records requests while it is open. Open it before triggering navigation.

Or skip the browser setup

If you need a screenshot of a URL rather than a Puppeteer redirect trace, ScreenshotNeo returns a screenshot or PDF with one GET request. Its clean-shot steps accept cookie and consent banners like a visitor, then remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents.

For example, using cURL:

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

See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card.

Frequently Asked Questions

Does redirectChain() include the final URL?

It returns requests preceding the current request in the chain; the final navigation response’s URL is available from the response itself.

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

Do I need request interception to trace redirects?

No. Use the navigation response’s request chain or page request and response events for ordinary redirect tracing.

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.

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.