@browsermcp/mcp Fails to Start on Windows Due to Port Check Command Failure When Port 9009 is Free
I tried to create a Client MCP to use the Browser MCP (windows 11)
Problem Description:
When attempting to start the @browsermcp/mcp server using npx @browsermcp/mcp@latest on Windows, the process fails immediately if TCP port 9009 is not currently in use. This prevents the server from starting under normal conditions where the required port is already available.
Steps to Reproduce:
Ensure no process is listening on TCP port 9009 on a Windows machine. This can be verified by running netstat -ano | findstr ":9009" in CMD or PowerShell, which should return no output.
Open a terminal (CMD or PowerShell). Running as a regular user or as Administrator produces the same error.
Run the command: npx @browsermcp/mcp@latest
Expected Behavior:
The server should successfully initialize or at least proceed past the initial port check/cleanup phase without error, eventually waiting for a client connection via stdio or other configured transport.
Actual Behavior:
The command fails immediately upon execution, printing the following error to stderr:
Failed to kill process on port 9009: Error: Command failed: FOR /F "tokens=5" %a in ('netstat -ano ^| findstr :9009') do taskkill /F /PID %a
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at checkExecSyncError (node:child_process:891:11)
at execSync (node:child_process:963:15)
at killProcessOnPort (file:///C:/Users/[YourUsername]/AppData/Local/npm-cache/_npx/[CacheHash]/node_modules/@browsermcp/mcp/dist/index.js:172:7)
at createWebSocketServer (file:///C:/Users/[YourUsername]/AppData/Local/npm-cache/_npx/[CacheHash]/node_modules/@browsermcp/mcp/dist/index.js:185:3)
at createServerWithTools (file:///C:/Users/[YourUsername]/AppData/Local/npm-cache/_npx/[CacheHash]/node_modules/@browsermcp/mcp/dist/index.js:205:21)
at createServer (file:///C:/Users/[YourUsername]/AppData/Local/npm-cache/_npx/[CacheHash]/node_modules/@browsermcp/mcp/dist/index.js:708:10)
at Command.
resolve the issue
I'm having the same problem on Arch Linux, total blocker:
Failed to kill process on port 9009: Error: Command failed: lsof -ti:9009 | xargs kill -9
kill: not enough arguments
This isn't a platform agnostic approach.
Same issue here. With Roo Code, windows 11, tries to kill task on 9009 port and doesn't find any then fails to install server.
I have little workaround i came up with. Create simple node server with listening port on 9009 outside of vs code, close vs code, run the server and then run vs code again so it will kill your server on 9009 port and will run :) For now this worked.
Yeah that works. On Linux I shimmed the lsof to just return what it expects. This is pretty easy to fix and low hanging fruit for the community. I'll end up submitting a patch if nobody else gets to it when I can find some time.
If you're like me and keep getting failed: FOR /F "tokens=5" %a in ('netstat -ano ^| findstr :9009') do taskkill /F /PID %a no matter what you try, consider reinstalling Node.js and npm to resolve the issue.
I resolved it in different way:
I added one if in function createWebSocketServer in already installed file @browsermcp/mcp/dist/index.js
On Linux Mint I have this file in ~/.npm/_npx/6ddf87659f2ad8a4/node_modules/@browsermcp/mcp/dist/index.js
It seems it is in /src/ws.ts on repo.
before
async function createWebSocketServer(port = mcpConfig.defaultWsPort) {
killProcessOnPort(port);
while (await isPortInUse(port)) {
await wait(100);
}
return new WebSocketServer({ port });
}
after
put all in if (await isPortInUse(port)) {...} to stop killing program on port 9009 even if it doesn't exist
async function createWebSocketServer(port = mcpConfig.defaultWsPort) {
if (await isPortInUse(port)) {
killProcessOnPort(port);
while (await isPortInUse(port)) {
await wait(100);
}
}
return new WebSocketServer({ port });
}
这是来自QQ邮箱的自动回复邮件。您好,我有点事情不在,无法亲自回复您的邮件。我将在事情结束后,尽快给您回复。
Browser MCP has been completely rewritten, so most open issues should now be resolved. I'm closing this issue as part of a cleanup. If the problem persists on the latest version, you're welcome to file a new issue.
这是来自QQ邮箱的自动回复邮件。您好,我有点事情不在,无法亲自回复您的邮件。我将在事情结束后,尽快给您回复。