BrowserMCP fails to start: 'Failed to kill process on port 9009' when port 9009 is free
Why does
npx @browsermcp/mcp@latestcrash immediately on Windows 11 withFailed to kill process on port 9009: Error: Command failed: FOR /F "tokens=5" %a in ('netstat -ano ^| findstr :9009') do taskkill /F /PID %awhen nothing is listening on port 9009? The same startup failure happens on Linux with anlsof -ti:9009 | xargs kill -9error, so it is not Windows-specific.Originally asked on GitHub: https://github.com/BrowserMCP/mcp/issues/14
5 answers
Status: still open — the thread contains no maintainer response or fix release as of the last update (July 2025).
The reporter's analysis points to the startup port-cleanup step. BrowserMCP calls
killProcessOnPort(9009)before starting its WebSocket server; on Windows that runsFOR /F "tokens=5" %a in ('netstat -ano ^| findstr :9009') do taskkill /F /PID %aand on Linuxlsof -ti:9009 | xargs kill -9. When port 9009 is free, the netstat/lsof output is empty, the kill command exits with status 1, and startup aborts instead of continuing.Workarounds that worked in the thread:
-
Occupy port 9009 first (Windows). Start any simple Node server that listens on TCP 9009 before launching
npx @browsermcp/mcp@latest; the startup routine finds a PID, kills it, and proceeds. -
Patch the installed
dist/index.js(Linux Mint). In~/.npm/_npx/<hash>/node_modules/@browsermcp/mcp/dist/index.js, guard the cleanup so it only runs when the port is in use (source issrc/ws.tsin the repo):
jsasync function createWebSocketServer(port = mcpConfig.defaultWsPort) { if (await isPortInUse(port)) { killProcessOnPort(port); while (await isPortInUse(port)) { await wait(100); } } return new WebSocketServer({ port }); }As general advice: this patch lives in the npx cache and is lost when the package is re-fetched, so you may need to reapply it after updates. One commenter also suggested reinstalling Node.js/npm, but did not report a result. Another shimmed
lsofon Linux to return the expected output; details were not given.Security note: startup force-kills whatever process is listening on port 9009, so don't launch it while an unrelated service is bound to that port.
Did this work for you?-
What @reas24 tried on GitHub (Worked)
Started a simple Node server listening on port 9009 outside VS Code, then reopened VS Code so BrowserMCP's startup port-kill finds a PID to kill instead of failing.
Source: https://github.com/BrowserMCP/mcp/issues/14#issuecomment-2838597296 (opens external site)
Did this work for you?What @furas tried on GitHub (Worked)
Edited the installed
@browsermcp/mcp/dist/index.json Linux Mint to wrap the kill/wait logic inif (await isPortInUse(port)), so nothing is killed when port 9009 is free.Source: https://github.com/BrowserMCP/mcp/issues/14#issuecomment-3064466293 (opens external site)
Did this work for you?What @eriknelson tried on GitHub (Outcome unclear)
On Linux, shimmed the
lsofcommand to return what it expects so thelsof -ti:9009 | xargs kill -9step succeeds; no details were given.Source: https://github.com/BrowserMCP/mcp/issues/14#issuecomment-2838820223 (opens external site)
Did this work for you?What @mydvdf tried on GitHub (Outcome unclear)
Suggested reinstalling Node.js and npm to resolve the recurring
FOR /F ... taskkillfailure, but did not report whether it fixed anything.Source: https://github.com/BrowserMCP/mcp/issues/14#issuecomment-2888873019 (opens external site)
Did this work for you?
Related questions
- Why are workspace packages missing from BrowserMCP and does its extension send telemetry?
- BrowserMCP clicks fail with 'Error: No tab with given id' in Claude Desktop and Claude Code
- BrowserMCP Shows '0 Tools Enabled' in Cursor 1.1.6 Despite Config
- browser_click times out on PubMed filters (WebSocket response timeout after 30000ms)
- BrowserMCP browser_get_console_logs returns empty after browser_navigate or refresh?