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

**URL:** <https://forum.cursor.com/t/cursor-occupying-ports-and-not-freeing-up-when-the-terminal-window-is-killed/134793>\
**Category:** Bug Reports\
**Created:** [September 24, 2025, 2:33pm UTC](https://forum.cursor.com/t/cursor-occupying-ports-and-not-freeing-up-when-the-terminal-window-is-killed/134793 "2025-09-24T14:33:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![valipokkann](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/valipokkann/32/72632_2.png) [@valipokkann](https://forum.cursor.com/u/valipokkann)\
**Post date:** [September 24, 2025, 2:33pm UTC](https://forum.cursor.com/t/cursor-occupying-ports-and-not-freeing-up-when-the-terminal-window-is-killed/134793/1 "2025-09-24T14:33:41Z")

</div>

### 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

 ![Screenshot 2025-09-24 at 20.02.48.png](https://us1.discourse-cdn.com/cursor1/original/3X/d/1/d147796d4adb01f3f1b3ddd4210f228ce011a4ee.png)

### 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

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [September 24, 2025, 3:45pm UTC](https://forum.cursor.com/t/cursor-occupying-ports-and-not-freeing-up-when-the-terminal-window-is-killed/134793/2 "2025-09-24T15:45:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [October 16, 2025, 3:45pm UTC](https://forum.cursor.com/t/cursor-occupying-ports-and-not-freeing-up-when-the-terminal-window-is-killed/134793/3 "2025-10-16T15:45:51Z")

</div>

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