在Eclipse中,我得到了这个错误:

run:
     [java] Error creating the server socket.
     [java] Oct 04, 2012 5:31:38 PM cascadas.ace.AceFactory bootstrap
     [java] SEVERE: Failed to create world : java.net.BindException: Address already in use: JVM_Bind
     [java] Java Result: -1
BUILD SUCCESSFUL
Total time: 10 seconds

我不知道为什么现在出现了,但几个小时前它运行得很好。我需要重新启动我的机器吗?我该怎么查到底呢?感谢您的建议和建议。


当前回答

对于windows:

查找进程id Netstat -nao |查找8080

它将以数字的形式向您显示进程ID。

例子:

TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       18856

这里18856是进程ID

终止这个过程 taskkill /PID 18856 /F

输出:SUCCESS: PID为18856的进程已被终止。

在这里使用taskkill是在杀死进程ID:18856

linux / Mac:

sudo kill -9 $(sudo lsof -t -i:8080)

在这里,您可以使用sudo lsof -t -i:8080找到端口8080的进程,并使用sudo kill命令杀死它

其他回答

对于windows:

查找进程id Netstat -nao |查找8080

它将以数字的形式向您显示进程ID。

例子:

TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       18856

这里18856是进程ID

终止这个过程 taskkill /PID 18856 /F

输出:SUCCESS: PID为18856的进程已被终止。

在这里使用taskkill是在杀死进程ID:18856

linux / Mac:

sudo kill -9 $(sudo lsof -t -i:8080)

在这里,您可以使用sudo lsof -t -i:8080找到端口8080的进程,并使用sudo kill命令杀死它

是的,正如Guido Simone所说,这是因为另一个进程侦听相同的端口。如果你使用的是Ubuntu,你可以简单地杀死这个进程 Sudo kill $(Sudo lsof -t:[端口号])

sudo kill $(sudo lsof -t:8080)

但有一次它对我不起作用。 我下了命令

$ lsof -i:[port] 

它什么也没有显示。

我使用命令检查了我的docker容器 Docker ps -a,但他们都死了。所有集装箱都停了 (但我记得,我停了一个集装箱,几分钟前使用的是同一个港口。)为了确保docker不是原因,我使用命令sudo service docker stop停止整个docker进程,然后再试一次。 令人惊讶的是eclipse当时并没有显示错误。它完美地运行了我的程序。

希望我的经验能帮助到一些人。

I faced similar issue in Eclipse when two consoles were opened when I started the Server program first and then the Client program. I used to stop the program in the single console thinking that it had closed the server, but it had only closed the client and not the server. I found running Java processes in my Task manager. This problem was solved by closing both Server and Client programs from their individual consoles(Eclipse shows console of latest active program). So when I started the Server program again, the port was again open to be captured.

在Mac:

杀进程 Terminal: kill <pid>

找到pid: 终端:lsof -i:<端口>

来自Diego Pino的回答

当另一个进程已经在指定端口(8080)上运行时,就会出现这个BindException异常。

您可以使用以下方法中的任何一种。

修改服务器端口号:如果使用Tomcat服务器和IntelliJ IDE,可以通过配置Tomcat服务器来配置服务器端口号

or

进入“tomcat>conf”文件夹 编辑server.xml 搜索“连接器端口” 将“8080”替换为端口号 重启tomcat服务器。

终止该端口中正在运行的现有进程并启动服务器。

对于Linux / Mac Sudo kill -9 $(Sudo lsof -t:8080) 对于Windows Netstat -ano | findstr:8080 taskkill /PID typeyourPIDhere /F 注意:(/F强制终止进程)