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

Call response.url() on a Puppeteer HTTPResponse. It returns the response URL as a string. For navigation, check that page.goto() did not return null before calling the method.

Get a response URL

HTTPResponse.url() is the method for reading the URL associated with a response:

const url = response.url();
console.log(url);

It is synchronous: do not use await. The official Puppeteer API reference describes it as returning the URL of the response, with a string return type.

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

Read the URL returned by page.goto()

page.goto() resolves to the main navigation resource’s response, or null in documented cases. Guard against null before reading its URL:

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

if (response) {
  console.log(response.url());
}

The navigation result can be null when navigating to about:blank or to the same URL with only a different hash. See the Page.goto() API reference for its return behavior.

Get the final URL and inspect redirects

When navigation follows redirects, page.goto() resolves with the response for the last redirect. Therefore, response.url() gives the final response URL, not the original address you passed to page.goto().

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
const response = await page.goto('http://example.com');

if (response) {
  console.log('Response URL:', response.url());
  const redirects = response.request().redirectChain();
  console.log('Redirected from:', redirects.map(request => request.url()));
}

The redirect chain contains the earlier requests in the sequence; the final response’s request is not itself an earlier redirect. With no redirects, the chain is empty. For a request URL, use HTTPRequest.url(); for the response URL, use HTTPResponse.url(). The redirectChain() API reference documents the chain.

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

Handle status codes and missing responses

  • Navigation returned null: there is no response object and thus no response URL to read. Check the value before calling url().
  • Response status is 404 or 500: an HTTP error status can still come with a response. Read its URL normally, and call response.status() if you also need to check the status.
  • You need the original URL before redirects: inspect response.request().redirectChain() and map each request to its url(). The returned response URL alone identifies the final response.
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 a screenshot rather than Puppeteer response metadata, ScreenshotNeo can capture a page with one GET request. Its API also provides response verdict and billing headers; it is not a replacement for Puppeteer’s HTTPResponse.url() when you need the navigation response URL.

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
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation. Cookie banners, newsletter popups and chat widgets are removed before capture; bot checks, blank pages and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo, or sign up for the free plan.

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.