To log page requests and responses in Puppeteer, attach request, response, and optionally requestfailed listeners before calling page.goto(). Log response status codes as well as URLs: an HTTP 404 or 503 is still a received response, not a failed network request.
Log requests and responses before navigation
Puppeteer’s Network logging guide documents page events for observing requests and responses. Register the listeners before navigation so you can capture the initial document request and early subresources. This runnable ES-module example prints the HTTP method and URL for each request, the status and URL for each response, and available failure details:
As an Amazon Associate I earn from qualifying purchases.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
page.on('request', request => {
console.log('→', request.method(), request.url());
});
page.on('response', response => {
console.log('←', response.status(), response.url());
});
page.on('requestfailed', request => {
const failure = request.failure();
console.error('×', request.url(), failure?.errorText ?? 'failure text unavailable');
});
await page.goto('https://example.com');
} finally {
await browser.close();
}
The example uses Puppeteer’s page events and request/response objects; it is not a claim of a test run. See the Puppeteer Network logging guide and the HTTPRequest API reference.
Understand the request lifecycle
requestfires when the page issues a request.responsefires when a response arrives. The response event gives you the status and URL to log.requestfinishedfires after the response body is downloaded and the request completes.requestfailedis emitted when the request fails instead of completing withrequestfinished. Itsfailure()result can be null, and error text may be unavailable, so guard both.
An HTTP error status is not the same as a transport failure. A server response with status 404 or 503 normally still follows the response and request-finished path; it does not, by itself, trigger requestfailed. Log response.status() to identify HTTP errors. See HTTPRequest.failure() and the PageEvent reference.
#1 Best Overall
Redirects also create multiple log entries: the request that receives a redirect response finishes, then the browser issues a new request to the redirected URL. Treat the resulting URLs as a chain of requests rather than expecting one entry whose URL changes in place.
Choose event logging or interception
| Approach | Use it for | What to account for |
|---|---|---|
| Page event logging | Observing URLs, methods, response statuses, and request lifecycle events. | Listeners report events; they are the simpler choice when you do not need to change traffic. |
| Request interception | Modifying, aborting, continuing, or fulfilling requests. | After interception is enabled, requests can stall until resolved (unless completed using the browser cache). Handlers must reliably resolve requests and account for requests already handled by another handler. |
For logging alone, leave interception off. The Puppeteer Request Interception guide explains the extra handling required when controlling traffic; the Page.setRequestInterception() API documents the setting.
Rank #2
Filter output and remove listeners cleanly
Request objects expose properties such as URL, method, headers, post data, and resource type. Filter inside the event callback when you only need a host or resource category, rather than printing every request. Avoid sending authorization headers, cookies, or sensitive request bodies to shared logs.
Use a named callback when the logger should stop before the page closes. Puppeteer’s Page is an event emitter, and its API supports removing listeners:
function logRequest(request) {
console.log(request.url());
}
page.on('request', logRequest);
// Later, when logging is no longer needed:
page.off('request', logRequest);
See the Puppeteer Page API reference.
Troubleshoot missing or confusing log entries
- The first page URL is missing: listeners may have been attached after navigation started. Register them before
page.goto(). - A 404 or 503 does not appear under failures: that is expected for an HTTP response. Inspect the
responseevent’s status instead. - A failure has no explanation:
request.failure()can be null or lack useful text. Keep logging the URL and use a fallback message, as in the example. - You see several URLs for one navigation: redirects issue a new request for the destination. Read the entries as a redirect chain.
- Requests appear to hang after enabling interception: ensure every intercepted request is resolved and check whether another handler already handled it. If the goal is only logging, disable interception and use page events.
- The log is too noisy or exposes sensitive data: filter by host, method, or resource type and do not print credentials, cookies, authorization headers, or private bodies into shared logs.
What page event logs do not promise
These page listeners are the documented route for observing page requests and responses. The cited Puppeteer references do not establish that this method captures every possible network operation from every browser, worker, or service-worker context, so do not treat the output as a guaranteed exhaustive browser-wide trace.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If you need a rendered screenshot rather than an event-by-event request log, ScreenshotNeo is a website screenshot API with a single GET request. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents take screenshots; and 1,000 screenshots per month are free with no card, with paid plans starting at $5 for 3,000.
For API details and options, see the ScreenshotNeo documentation.
Recommended Free Tools
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Sign up for 1,000 free screenshots a month, with no card required.
Quick Recap
Best Value
- Used Book in Good Condition
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.




