Quick Fix: One Command with portrm
The fastest way to kill port 3000 on a Mac is with portrm. It finds the process, identifies the service, checks if it is safe to kill, and frees the port:
$ ptrm fix 3000
Port 3000 in use
Next.js dev server (PID 48291) - node
SAFE - development server
Fix port 3000? [Y/n] Y
Killed PID 48291
Port 3000 is now free
Install with brew install abhishekayu/tap/portrm or npm install -g portrm.
Method 1: lsof + kill
The standard macOS approach uses lsof to find the process and kill to terminate it:
# Step 1: Find what is using port 3000
$ lsof -i :3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 48291 dev 23u IPv6 0x... 0t0 TCP *:hbci (LISTEN)
# Step 2: Kill the process by PID
$ kill -9 48291
The -i :3000 flag tells lsof to show processes listening on port 3000. The PID column gives you the process ID to kill.
One-liner version
Combine both steps into a single command:
$ kill -9 $(lsof -ti :3000)
The -t flag makes lsof output only the PID, which gets passed directly to kill.
Method 2: Activity Monitor
If you prefer a GUI approach:
- Open Activity Monitor (Spotlight: Cmd+Space, type "Activity Monitor")
- Click the Network tab
- Use the search bar to find the process name (e.g., "node")
- Select the process and click the X button in the toolbar
- Choose Force Quit
This works but does not tell you which port a process is bound to. Use lsof or ptrm first to identify the right process.
Method 3: Using fuser
Some macOS setups have fuser available:
$ fuser 3000/tcp
3000/tcp: 48291
$ kill -9 48291
What Typically Uses Port 3000 on Mac?
| Application | Why It Uses 3000 |
|---|---|
| React (Create React App) | Default dev server port |
| Next.js | Default next dev port |
| Express.js | Common convention in tutorials |
| Ruby on Rails | Default Puma server port |
| Grafana | Default dashboard port |
Prevent Port 3000 Conflicts on Mac
Instead of killing processes every time, configure your project to handle port conflicts automatically:
# Create a .ptrm.toml in your project root
$ ptrm init
# Check if port 3000 is free before starting your server
$ ptrm preflight 3000 && npm run dev
# Or auto-fix conflicts before starting
$ ptrm fix 3000 -y && npm run dev
Troubleshooting
lsof shows nothing but port 3000 is still in use
The process might be in a TIME_WAIT state. Wait 30-60 seconds for the OS to release it, or use:
$ ptrm scan | grep 3000
portrm detects TIME_WAIT sockets and shows their remaining timeout.
Permission denied when killing the process
The process may be running as root. Prefix with sudo:
$ sudo kill -9 $(lsof -ti :3000)
# Or with portrm
$ sudo ptrm fix 3000
Stop Googling lsof flags
portrm identifies the service on port 3000, checks safety, and kills it in one command. 1.2 MB, zero dependencies.