Skip to content
Edith

Guide

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.

Updated by

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
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 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
lsof -nP -iTCP:3000 -sTCP:LISTENkill 48213kill -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 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, 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. 1

    Install Ports

    Open Library in Edith, find Ports and click Install. It appears under Developer in the sidebar.

  2. 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. 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. 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
ed ports who 3000ed ports kill 3000 --yesed ports ls --all

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, 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. For a full development setup, see the terminal with broadcast input and managing servers from your Mac. Ports is one of many tools in Edith; the pricing page lists what one license covers.

One app. Every tool your Mac is missing.

Pay once · No account · 30-day refund · macOS 14+ on Apple silicon