SpawnSweep

Port 3000 already in use on Mac? Find and free it

Run lsof -nP -iTCP:3000 -sTCP:LISTEN in Terminal to see what is listening on TCP port 3000. Check the process and its working directory before stopping it. A previous next dev command can still own the port after you finish a Claude Code, Codex or Cursor session.

Identify the server and project

lsof -nP -iTCP:3000 -sTCP:LISTEN

The COMMAND column shows the executable and PID identifies the process. When the executable is a generic name like node, use the PID to see its full command and working directory. Replace 12345 with the PID you found.

ps -p 12345 -o pid,ppid,command
lsof -a -p 12345 -d cwd

A working directory inside another checkout or Git worktree often explains why the server belongs to someone else’s project or another task of your own. For a different port, substitute its number in the first command.

Stop the server and verify the port

  1. If you still have the original terminal, press Control-C there. For a service managed by a runner such as Docker Compose, stop the service through that runner.
  2. For a standalone process you own, check its PID again and run kill -TERM 12345 using the verified PID.
  3. Rerun the first lsof command. If the listener returns with a new PID, look for the parent watcher or runner that restarted it. If the old service is still needed, leave it running and configure the new server to use a different port.

See man lsof, man ps and man kill in macOS Terminal for command details.

Find a busy port from the menu bar

Open Ports in SpawnSweep to see local listeners together. Where the app can identify them, the row includes the project, Git branch and agent session. Select Free port on the listener you recognize and review the process before confirming. Pinned sessions and protected ports stay blocked from this action.

If a port conflict is one symptom of a finished coding session, review its other leftover processes.

Why can the browser load a different project after I restart my server?

An old server can keep serving port 3000 while your new server selects another port. Compare the startup URL in your terminal with the URL in your browser. The localhost port guide also covers IPv6, Docker mappings and protected ports.

A 20-second illustrated demo shows sample coding sessions with occupied ports, background processes, and booted simulators. SpawnSweep groups their leftovers for review.
Download for Mac All Mac cleanup guides

Free, open-source app for macOS 14 or later on Apple silicon. Install details