DEV Community

Cover image for How I Manage Localhost Port Conflicts With an AI Agent
Rizèl Scarlett for Block Open Source

Posted on • Edited on • Originally published at block.github.io

11 3 3 1 1

How I Manage Localhost Port Conflicts With an AI Agent

Localhost Ports Hoarding

I'm perpetually drowning in open tabs. Yes, I do need Bluesky, ChatGPT, Claude, Goose, Cursor, Discord, Slack, Netflix, and Google Docs all open at the same time. I've learned that tab management isn't my only vice.

"Hi, my name is Rizel, and I'm a localhost ports hoarder. 👋🏿"

It always starts innocently with me running one project that uses localhost:3000. Then a teammate pings me to review their PR. Their project also runs on localhost:3000. Fortunately, modern frameworks are smart enough to automatically bump to ports 3001 or 3002. Before I know it, 3003, 3004, and 3005 are running too, and my laptop sounds like it’s about to take off as it crawls under the weight of too many processes.

Traditional Ports Management

Typically, freeing up ports involves running the following commands:

# Step 1: list all open ports
lsof -i -P | grep LISTEN

# Step 2: find a specific port
lsof -i :3000

# Step 3: kill the process
kill -9 98026
Enter fullscreen mode Exit fullscreen mode

Because I don't do this often, I often end up searching for the commands, which derails what I was initially working on.

Using Goose as My Port Manager

To avoid that interruption, I started offloading the task to Goose, an open source AI agent.

Goose uses its built-in Developer MCP server to handle coding-related tasks on my machine. Here's what the interaction looks like:

Prompt to Goose:

Can you tell me which ports I have running?
Enter fullscreen mode Exit fullscreen mode

Goose Response:

Development Servers:
- Node.js servers on ports 3000, 3001, 3002
- Port 18030

Database:
- PostgreSQL on port 5432

Development Tools:
- Ollama on port 11434
- Multiple Goose instances (ports 49377, 49899, 63594, 64365)

Applications:
- Okta Verify (port 8769)
- inSync (ports 7010, 49831, 49830)
- Pieces (ports 39300, 62638)
- Rapportd macOS service (port 60151)
Enter fullscreen mode Exit fullscreen mode

Prompt to Goose:

Kill all the Node.js servers running on localhost.
Enter fullscreen mode Exit fullscreen mode

Goose Response:

The command executed successfully, freeing up ports 3000, 3001, and 3002.
Enter fullscreen mode Exit fullscreen mode

Why Use AI for Simple Tasks

Freeing up ports is something I know how to do. But I use AI tools like Goose for small tasks that create friction and slow me down. I'm not trying to cram more work into the day. My goal is to work efficiently, make a positive impact, and still have time for my personal life.

Top comments (9)

Collapse
 
dotallio profile image
Dotallio

I totally get this, I keep forgetting the kill commands too. Do you use Goose for any other quick fixes like this, or is it mostly for ports?

Collapse
 
blackgirlbytes profile image
Rizèl Scarlett

I use it for a TON of stuff. Not just ports. I'm going to try to write about the different things I use Goose for. I just tend to forget to document the way I use it in the moment 😆

Collapse
 
nathan_tarbert profile image
Nathan Tarbert

Been there with twenty projects clogging my ports - smart way to cut the pointless fiddling and just get stuff moving.

Collapse
 
xwero profile image
david duymelinck

This could be two aliases.

alias findports='lsof -i -P | grep LISTEN'
alias killport='f() { sudo kill -9 $(sudo lsof -t -i:$1); }; f'
Enter fullscreen mode Exit fullscreen mode

No need to send data to an AI.

Collapse
 
blackgirlbytes profile image
Rizèl Scarlett

good point! i dont really use aliases like that, so might not be top of mind for me. And I use local AI app with a local model so data is staying on my device!

Collapse
 
xwero profile image
david duymelinck

It is less about data privacy, more about the over use of AI.
It is easier to use an AI if you have no idea, but if you have some knowledge it is easy to write a few lines of code.

Collapse
 
deividas_strole profile image
Deividas Strole

To manage localhost port conflicts, I use an AI agent that detects which process is using the port, suggests alternatives, and can auto-update configs or stop non-critical processes. This saves time and keeps my development smooth.

Collapse
 
nevodavid profile image
Nevo David

Been there way too many times, honestly. Offloading stuff like this is a lifesaver.

Collapse
 
moopet profile image
Ben Sinclair

Clever idea.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.