We'll be using port number 3000 as the example
Ubuntu
Option 1:
Step One:
Get the process id
sudo netstat -lpn |grep :3000
You will get an output similar to this
tcp6 0 0 :::3000 :::* LISTEN 1234/node
Step Two:
Now that you have the process id - which is 1234 in this example
Kill the process using the code below
kill -p 1234 OR kill -9 1234
Option 2:
fuser -k 3000/tcp
Windows
Step One
Open up cmd.exe (we may need to run it as an administrator, but this isn't always necessary). Run the below command:
netstat -ano | findstr :<PORT>
netstat -ano | findstr :3000
The arrow shows the PID (process identifier). Locate the PID of the process that's using the port you want.
Step Two
taskkill /PID <PID> /F
taskkill /PID 4692 /F
Step Three
You can check if the operation was successful by re-running the command in "Step 1". You shouldn't see any more search results for that port number.
Top comments (0)