Solution skill
Playwright MCP: browser closed after idle timeout (set --idle-timeout)
Complete solution
Fixes Playwright MCP closing the browser after an hour with no tool calls, so the next call fails. Use when long agent sessions hit browser-has-been-closed errors after idle periods. Not for the 0.0.73 launchApp regression.
TL;DR
A headless browser launched by the server is closed after an hour without tool calls to save CPU; the next call then fails because there is no browser. Pass --idle-timeout (milliseconds) to raise it, or 0 to disable. Logins survive only if you also persist state, since --isolated memory state is lost on close.
The error
Target page, context or browser has been closedFix it
Add
--idle-timeoutto your MCP config args. For a 5-minute window:{ "mcpServers": { "playwright": { "command": "npx", "args": ["@playwright/mcp@latest", "--idle-timeout=300000"] } } }Use
0to disable the timeout entirely.- Expected: valid JSON.
Restart the client and run a long session.
- Expected: the browser stays up across idle gaps up to your timeout.
If logins must survive, also persist state: use a persistent profile or
--storage-state, because with--isolatedthe in-memory cookies die with the browser anyway.- Expected: re-login not needed after idle closes.
When to use
- Browser works, then after a long idle stretch the next tool call fails with browser-closed.
- Agent sessions span hours with gaps between browser actions.
When NOT to use
- Browser dies between rapid successive calls on 0.0.73 - that is the launchApp regression, pin 0.0.72.
- Browser never launches - check the install.
Compatibility
- @playwright/mcp with
--idle-timeoutsupport.
Root cause
An animating page costs CPU as long as the browser is open, and agent sessions last hours. The server therefore reaps headless browsers after 60 minutes of no completed tool calls. Headed browsers and --cdp-endpoint/--extension attached browsers are never auto-closed; an explicit timeout on those only disconnects, leaving pages open.
Edge cases
- The timer never fires mid-call; it only counts completed-call idle time.
- The next tool call after a close launches a fresh browser automatically, so the agent must navigate again.
- With
--shared-browser-context, the timer spans all clients: the browser closes only once every client has been idle.
Evidence
Playwright MCP documentation for the idle timeout: a headless browser launched by the server is closed after an hour without tool calls, with --idle-timeout setting the timeout in milliseconds (0 disables it). With --isolated, cookies and in-memory storage are lost on close, so a persistent profile or --storage-state is needed to keep logins.
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_cyN2-E9vYtsmmYLa2SHhKw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Playwright MCP: browser closed after idle timeout (set --idle-timeout) <span>— Vectle</span></a>