When developing web applications or managing local servers, you may encounter an error stating that Port 8019 or <your port> is already in use. This typically happens when a previous process didn't shut down correctly.
Follow this guide to identify and kill the process occupying port 8019 on your Mac using the Terminal.
Step 1: Identify the Process ID (PID)
First, you need to find the unique ID of the application using the port.
- Open your Terminal (Command + Space, then type "Terminal").
- Run the following command:
bash
sudo lsof -i :8019
3. Look at the output table. Find the number listed under the PID column (e.g., 12345).
Step 2: Terminate the Process
Once you have the PID, you can stop it using the kill command.
Option A: Standard Stop (Recommended)
This tells the application to save its state and close down naturally:
bash
kill <PID>
Use code with caution.
(Replace <PID> with the number you found in Step 1)
Option B: Force Stop
If the application is frozen or won't close, use a "Force Kill":
bash
sudo kill -9 <PID>
The Pro Shortcut: One-Line Command
If you want to skip the manual lookup and stop the process instantly, copy and paste this command into your Terminal:
bash
sudo kill -9 $(lsof -t -i:8019)