Cursor occupying ports and not freeing up when the terminal window is killed

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Cursors’ new feature doesn’t allow us to edit agent-managed CLI. However, it sometimes runs an npm dev server when I’m already running one on port 3000.

Alternatively, it kills my dev server and starts a new one. But when the agent-managed terminal is killed, the port it used remains in use, and I have to manually kill it.

Steps to Reproduce

it hapoens when building a typescript site, it runs npm dev server on a port, now you click open in external terminal to see what its doing (sometimes it keep waiting after error or if terminal goes to limbo) now i kill the termina with dustbin button. twhen i manually start the dev server is not available again

Expected Behavior

when a terminal is killed the process started by it should be killed

Screenshots / Screen Recordings

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.6.45
VSCode Version: 1.99.3
Commit: 3ccce8f55d8cca49f6d28b491a844c699b8719a0
Date: 2025-09-22T18:22:38.013Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.6.0

For AI issues: which model did you use?

grok fast

Does this stop you from using Cursor

No - Cursor works, but with this issue

1 Like

Hey, thanks for the report. This is a known issue with agent-managed terminals not properly cleaning up child processes when terminated. The terminal process gets killed but the npm dev server it spawned keeps running in the background.

A few workarounds while this gets fixed:

  • Use lsof -i :3000 to find the process using port 3000, then kill -9 [PID] to force kill it
  • Or run npx kill-port 3000 if you have that package installed
  • You can also try pkill -f "npm.*dev" to kill all npm dev processes

For now, try to avoid killing agent-managed terminals abruptly when they’re running dev servers. Instead, let the agent finish its task or use Ctrl+C in the terminal first before closing it.

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.