Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

macos - How can I kill whatever process is using port 8080 so that I can vagrant up?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This might help

lsof -n -i4TCP:8080 

The PID is the second field in the output.

Or try:

lsof -i -P

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...