How to Find and Kill the Process Using a Port on Mac
Every developer has faced it: you try to fire up your local development server, and your terminal screams: "Address already in use." It's a classic development friction point. Whether you are running a Node.js backend, a Docker container, or a local Python API, finding and killing the process that has hijacked your required port is a necessary skill for any macOS developer.
In this guide, we will walk you through the most efficient ways to identify and resolve port conflicts—from the traditional command-line approach to modern, streamlined visual alternatives.
Understanding Why Port Conflicts Happen
On macOS, a "port conflict" occurs when an application attempts to bind to a specific TCP or UDP port that is already being claimed by another process. Common culprits include:
- Zombie Processes: A previous instance of your development server didn't shut down properly when you closed your terminal or IDE.
- System Services: macOS background services, databases (like Postgres or Redis), or container engines (Docker) may have automatically claimed the port.
- Multiple Instances: Running the same service from two different terminal tabs.
Method 1: The Manual Approach (Using the Terminal)
If you prefer to stay inside your terminal, macOS provides built-in tools like lsof (List Open Files) to diagnose these issues. While powerful, it requires precision to avoid accidentally killing the wrong process.
Step 1: Identify the Process
To find which process is using a specific port (for example, port 3000), run the following command:
lsof -i tcp:3000
This will output a table containing the process name (COMMAND), the Process ID (PID), and the User. Look at the PID column; this is the number you need to identify the culprit.
Step 2: Kill the Process
Once you have the PID, you can terminate it. Start with a polite request:
kill [PID]
If the process refuses to close, you may need to force it:
kill -9 [PID]
Method 2: The Visual Approach (Using PortWatcher)
Manually scanning PIDs is tedious and prone to human error. For developers who prioritize flow state, manual terminal management is often unnecessary bloat.
PortWatcher is a native macOS menu bar app designed specifically to eliminate the need for manual command-line port management. Instead of running lsof, you can see all active ports in your menu bar and kill them with a single click.
Why Use a Visual Utility?
- Context Awareness: PortWatcher shows you the working directory of the process.
- Safety: By default, PortWatcher attempts a graceful termination (SIGTERM).
- Zero Latency: Because it is a native AppKit application, it runs with near-zero overhead.
Free your ports instantly
Use PortWatcher to see exactly what is holding your port hostage and free it with a single click—no terminal required.
Download PortWatcher Notarized by Apple · Distributed outside App Store