Skip to content
Puppeteer · error message

Puppeteer: Navigating frame was detached

RetryableFrames

Last verified

The exact message
Error: Navigating frame was detached

What it means

A navigation that Puppeteer was waiting on, from page.goto(), frame.goto() or page.waitForNavigation(), could not complete because the frame being navigated was removed. Puppeteer stops waiting and rejects with this message instead of a timeout.

On the main frame this typically means the page was closed or the renderer crashed during the navigation. Heavy pages in memory-limited containers, reusing a page that another part of the script closed, or a site that closes its own window during login all lead here. On iframes it means the iframe element was removed while it was loading.

What is not wrong: the URL. The same navigation in a fresh page usually succeeds, which is why this error tends to look intermittent and is often misread as a network problem.

What it looks like

async function gotoWithRetry(browser, url) {
  let page = await browser.newPage();
  try {
    await page.goto(url, { waitUntil: 'domcontentloaded' });
  } catch (err) {
    if (!/frame was detached/i.test(err.message)) throw err;
    if (!page.isClosed()) await page.close();
    page = await browser.newPage();
    await page.goto(url, { waitUntil: 'domcontentloaded' });
  }
  return page;
}

Why it happens

  • The browser or renderer crashed during navigation, often from memory pressure or a small /dev/shm.
  • The page was closed by other code while goto was pending.
  • An iframe being navigated was removed by its parent page.
  • The site closed its own window (popup or OAuth flow) mid-navigation.

How to fix it

  1. Listen for page.on('error') (renderer crash) and browser.on('disconnected') to confirm a crash.
  2. In Docker, add --shm-size=1gb or args: ['--disable-dev-shm-usage'], and give the container more memory.
  3. Make sure no other task can close the page while it navigates; one page per task.
  4. On this error, open a new page and retry the navigation once.

How to stop it recurring

Give Chrome enough shared memory and RAM, limit concurrent pages, and recycle the browser periodically in long crawls. Keep page ownership clear so only one task navigates or closes a given page, and log crash and disconnect events so intermittent failures can be correlated with memory usage.

Official documentation: pptr.dev/api/puppeteer.page.goto. See all Puppeteer error messages.

Related errors

Definitions

Quick answers

What does "Navigating frame was detached" mean in Puppeteer?

A navigation that Puppeteer was waiting on, from page.goto() , frame.goto() or page.waitForNavigation() , could not complete because the frame being navigated was removed. Puppeteer stops waiting and rejects with this message instead of a timeout. On the main frame this typically means the page was closed or the renderer crashed during the navigation.

How do I fix "Navigating frame was detached"?

1. Listen for page.on('error') (renderer crash) and browser.on('disconnected') to confirm a crash. 2. In Docker, add --shm-size=1gb or args: ['--disable-dev-shm-usage'], and give the container more memory. 3. Make sure no other task can close the page while it navigates; one page per task. 4. On this error, open a new page and retry the navigation once.

Run browser automation you can watch and take over

Autonoly runs each job in a real cloud Chromium browser driven by Playwright. Timeouts and detached elements still happen; the difference is that you can watch the run live, see the step that failed, and take control of the browser to finish it.

Also see Live browser control.