How can I kill whatever process is using port 8080 so that I can vagrant up?
Fast and quick solution:
lsof -n -i4TCP:8080
PID
is the second field. Then, kill that process:
kill -9 PID
Less fast but permanent solution
Go to
/usr/local/bin/
(Can use command+shift+g in finder)Make a file named
stop
. Paste the below code in it:
#!/bin/bash
touch temp.text
lsof -n -i4TCP:$1 | awk '{print $2}' > temp.text
pidToStop=`(sed '2q;d' temp.text)`
> temp.text
if [[ -n $pidToStop ]]
then
kill -9 $pidToStop
echo "Congrates!! $1 is stopped."
else
echo "Sorry nothing running on above port"
fi
rm temp.text
- Save this file.
- Make the file executable
chmod 755 stop
- Now, go to terminal and write
stop 8888
(or any port)
This might help
lsof -n -i4TCP:8080
The PID is the second field in the output.
Or try:
lsof -i -P