# How to Kill a Process on a Port on Mac

> The one-line Terminal fix, what each flag does, and a safer way to stop the right server when several are running.

- Canonical URL: https://getedith.pro/guides/kill-process-on-port-mac
- Published: 2026-12-03
- Updated: 2026-12-03

## The short answer

Open Terminal and run this, replacing 3000 with your port. It finds the process listening on that port and asks it to quit:

Terminal

Shell

```
lsof -ti tcp:3000 | xargs kill
```

If it is still there a few seconds later, run the same line with `kill -9` to force it. That is all most people need. The rest of this guide explains what the command does, how to check what you are about to stop, and how Edith's [see what is running on a port](https://getedith.pro/extensions/localhost-ports) extension, Ports, shows every local server with its project before you stop one.

## Method 1: lsof and kill in Terminal

Built into macOS

### Find the PID, then stop it

`lsof` lists open files, and on macOS network sockets count as files. Look before you stop anything:

Terminal

Shell

```
lsof -nP -iTCP:3000 -sTCP:LISTEN
kill 48213
kill -9 48213
```

- `-iTCP:3000` limits the list to TCP sockets on port 3000, and `-sTCP:LISTEN` keeps only the one accepting connections, not every browser tab talking to it.
- `-n` and `-P` skip name lookups, so the command answers instantly and shows numbers instead of service names.
- `kill` sends a polite terminate signal that lets the server close files and connections. `kill -9` ends it immediately and should be the second try, not the first.
- `-t`, used in the one-liner, prints only process IDs so they can be piped into `kill`.

`lsof` only sees your own processes unless you run it with `sudo`. If it prints nothing but the port is still busy, a process owned by another user or by macOS itself holds it.

## Method 2: Activity Monitor

Built into macOS

### Quit a process by name or PID

Open Activity Monitor, search for the process name or the PID you got from `lsof`, select it and click the stop button in the toolbar. Activity Monitor has no port column, so you still need `lsof` to learn which process owns the port. It helps when you want to see memory and CPU before you quit something.

## Method 3: a free menu bar app or npx

If you do this often, small free tools save typing. [PortKiller](https://github.com/productdevbook/port-killer) is an open source menu bar app (MIT license) that lists listening ports and kills a process from the list. In a JavaScript project, [kill-port](https://www.npmjs.com/package/kill-port), an MIT licensed npm package, does the same from the command line with `npx kill-port 3000`. Raycast users can install a free port manager extension from its store. All three were available when we checked in December 2026, and for a single port they are all you need.

## Where these methods fall short

- **A PID says nothing about the project.** Five `node` processes look the same in `lsof`. You find out which one you stopped when the wrong app goes down.
- **kill -9 is a blunt habit.** Forcing a database or a dev server to quit skips its cleanup, which can leave lock files or a half-written cache behind.
- **Nothing tells you what is exposed.** A server bound to every network interface is reachable from other machines on your Wi-Fi, and `lsof` output makes that easy to miss.
- **Forked servers.** Many dev servers spawn worker processes that share the port. Killing a worker does not free it, and the parent restarts the worker.

## The Edith way: Ports

Ports lists every process listening on your Mac with its port, the project folder it runs in, its command line, the user, when it started and how much CPU and memory it uses. It labels common servers such as Next.js, Vite, Rails, Django, FastAPI, PostgreSQL, Redis, MongoDB, Docker and Ollama, groups them by project, and marks the ones that listen on every interface as exposed. It needs no administrator rights and no special permissions.

1. **Install Ports**
   Open Library in Edith, find Ports and click Install. It appears under Developer in the sidebar.
2. **Find the server**
   Open Ports. Each listening server shows its port, a label such as Next.js or PostgreSQL, the project folder, CPU and memory. Use the All, Dev servers and Exposed filter at the top, or pick one project from the All projects menu, to narrow the list.
3. **Click Stop**
   Click Stop on the row. Edith asks "Stop Next.js on port 3000?" and, once you confirm, asks the process to exit and waits, 5 seconds by default. When forked workers share the port, only their parent is signalled, and macOS services are never stopped.
4. **Force stop only if needed**
   If the server did not exit in time, Edith says so and offers Force stop, which ends it at once without letting it clean up. You change the wait under Stopping in the Ports settings.

Each row also has Open, Copy address, Reveal and Terminal buttons, so you can load a dev server in your browser, show its folder in Finder or open a terminal there instead of stopping it. Click Refresh to scan again; otherwise the list refreshes every two seconds while it is on screen and does nothing in the background. Running dev servers also appear in the Ports widget on Home and the desktop.

### From the terminal

The same actions are commands. `kill` only previews until you add `--yes`, and secrets in command lines are masked.

Terminal

Shell

```
ed ports who 3000
ed ports kill 3000 --yes
ed ports ls --all
```

Port 5000 or 7000 on a newer Mac

If the holder is AirPlay Receiver, do not kill it: it restarts. Turn AirPlay Receiver off in System Settings, under General, then AirDrop & Handoff, or move your server to another port. Ports labels it and never stops it. The [port already in use guide](https://getedith.pro/guides/port-already-in-use-mac) covers this and other causes by framework.

## Which tool to use

- **Once in a while:** the `lsof` one-liner. It is built in and free.
- **Every day, ports only:** PortKiller or kill-port, both free and open source.
- **Several projects and servers at once:** Ports, when you also want project grouping, exposed-address flags and a careful stop. It comes with Edith, $35 once for one Mac with every other extension included, on macOS 14 or later on Apple silicon.

## Common questions

### Is kill -9 safe?

It always works on your own processes, but the process gets no chance to clean up. Try a plain `kill` first and give it a few seconds. Ports follows the same order on its own.

### Why does lsof show nothing but the port is still in use?

The holder belongs to another user, such as a system service or a process started with `sudo`. Run `sudo lsof -nP -iTCP:3000 -sTCP:LISTEN` to see it. Ports has the same limit, because it runs without administrator rights.

### Can I stop a process on a port on a remote server?

Over SSH, run the same `lsof` or `ss -ltnp` on the server. If you manage servers with Edith's [Machines](https://getedith.pro/extensions/ssh-machines), its Processes tab lists and stops processes there, and `ed machines exec` runs any command on a saved machine.

### Does Ports work for Docker containers?

It shows the Docker process that publishes the port and labels it. Stop the container itself with `docker stop` rather than killing Docker's port proxy.

## Keep going

If you came here because a server would not start, read [how to fix port already in use on a Mac](https://getedith.pro/guides/port-already-in-use-mac). For a full development setup, see the [terminal with broadcast input](https://getedith.pro/extensions/terminal) and [managing servers from your Mac](https://getedith.pro/use-cases/manage-servers-from-your-mac). Ports is one of many tools in Edith; the [pricing page](https://getedith.pro/pricing) lists what one license covers.

## Edith extensions used

- [See What Is Running on a Port on Mac](https://getedith.pro/extensions/localhost-ports): See and stop every local server you left running.
- [Terminal With Broadcast Input and Tabs for Mac](https://getedith.pro/extensions/terminal): A fast built-in terminal with tabs that keeps your shells in one place.
- [SSH Server Manager for Mac With Docker and Files](https://getedith.pro/extensions/ssh-machines): Watch, browse and run your servers and containers from one place.

## Related guides

- [How to Free Disk Space on a Mac for Developers](https://getedith.pro/guides/free-disk-space-mac-developers): Free disk space on a developer Mac: clear Xcode DerivedData, old simulators and package caches with built-in commands, or review and trash them safely.
- [Fix Port Already in Use on Mac (EADDRINUSE)](https://getedith.pro/guides/port-already-in-use-mac): Port 3000, 5000, 5173 or 5432 already in use on your Mac? Find the cause by framework, from a forgotten dev server to AirPlay Receiver, and fix it safely.

## Get Edith

Edith is a native Mac app for macOS 14 or later on Apple silicon with 100+ extensions, the `ed` command line and an MCP server. $35 once for one Mac, plus $7 for each additional Mac, with no subscription and a 30-day refund.

- [Buy Edith](https://getedith.pro/pricing): $35 once for one Mac, plus $7 for each additional Mac
- [Download Edith](https://getedith.pro/download): the installer, or Homebrew
