我该如何杀死正在使用端口8080的任何进程,以使自己无所事事? [英] How can I kill whatever process is using port 8080 so that I can vagrant up?

查看:365
本文介绍了我该如何杀死正在使用端口8080的任何进程,以使自己无所事事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MacOSX上,我使用Packer构建了一个Vagrant盒子,所以我需要不断地将其抬起并拆下.我正在尝试无所事事",并收到标准错误,因为该端口正在使用中:

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无法在此VM上转发指定的端口,因为它们将与已经在这些端口上侦听的其他应用程序冲突.转发到8080的端口已在主机上使用."

"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."

解决方案似乎很简单:我只需要确定将8080端口保持打开状态的进程并杀死该进程,对吗?这不是那么容易.

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.

如果我运行命令:

nmap localhost -p 8080

我收到以下输出:

PORT     STATE SERVICE
8080/tcp open  http-proxy


如果我运行以下命令:


If I run the following command:

top -o prt

1360年使用的最高端口

The highest port in use in 1360

如果我运行以下命令:

 netstat -tulpn | grep :8080

我收到:

netstat: n: unknown or uninstrumented protocol


如果我运行以下命令:


If I run the following command:

lsof -i :8080

我没有收到输出

如果我重新启动计算机,则该端口现在可用,并且现在可以无所事事了".

If I restart my computer, the port is now available and I can now 'vagrant up'.

如何使用端口8080终止任何进程,这样我就可以在不重新启动计算机的情况下无所事事?

How can I kill whatever process is using port 8080 so that I can vagrant up without restarting my computer?

推荐答案

这可能有帮助

lsof -n -i4TCP:8080 

PID是输出中的第二个字段.

The PID is the second field in the output.

或尝试:

lsof -i -P

这篇关于我该如何杀死正在使用端口8080的任何进程,以使自己无所事事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆