On MacOSX, I'm using Packer to build a Vagrant box so I need to continually bring it up and tear it down. I'm attempting to 'vagrant up', and receive the standard error because the port is in use:
"Vagrant cannot forward the specified ports on this VM, since they would collide with some other application that is already listening on these ports. The forwarded port to 8080 is already in use on the host machine."
The solution seems simple enough: I just need to identify the process that is holding port 8080 open and kill that process, right?. It's not that easy.
If I run the command:
nmap localhost -p 8080
I receive the following output:
PORT STATE SERVICE
8080/tcp open http-proxy
If I run the following command:
top -o prt
The highest port in use in 1360
If I run the following command:
netstat -tulpn | grep :8080
I receive:
netstat: n: unknown or uninstrumented protocol
If I run the following command:
lsof -i :8080
I receive no output
If I restart my computer, the port is now available and I can now 'vagrant up'.
How can I kill whatever process is using port 8080 so that I can vagrant up without restarting my computer?
It can be Cisco AnyConnect. Check if /Library/LaunchDaemons/com.cisco.anyconnect.vpnagentd.plist exists. Then unload it with launchctl and delete from /Library/LaunchDaemons
Fast and quick solution :
lsof -n -i4TCP:8080
PID is second field.
kill -9 PID
Less Fast but permanent solution
1.) Go to /usr/local/bin/ (Can use command+shift+g in finder)
2.) make file named stop. And paste below code in it.
3.) Save file. Enjoyyy!!. Go to terminal and write stop 8888 (or any port)
U can write this command (stop port) from anywhere in directory.
I needed to run this command
Then i got
show which service is using the PID
Then I got this
To uninstall cisco web security agent run
credits to: http://tobyaw.livejournal.com/315396.html
Run:
nmap -p 8080 localhost
(Install nmap with MacPorts or Homebrew if you don't have it on your system yet)Run:
ps -ef | grep http-proxy
Run:
ps -ef 640
(replace 501 with your UID)Port 8080 on mac osx is used by something installed with XCode SDK
In case above-accepted answer did not work, try below solution. You can use it for port 8080 or for any other ports.
Replace 3000 with whichever port you want. Run below command to kill that process.
PID is process ID you want to kill.
Below is the output of commands on mac Terminal.
You can also use the Activity Monitor to identify and quit the process using the port.