admin管理员组

文章数量:1654293

问题

Description:

Web server failed to start. Port 80 was already in use.

Action:

Identify and stop the process that's listening on port 80 or configure this application to listen on another port.

Disconnected from the target VM, address: '127.0.0.1:7936', transport: 'socket'

解决方法

这个错误消息表明你的Web服务器尝试启动时,端口80已经被另一个进程占用。因此,服务器无法绑定到端口80并启动。

解决步骤

1. 确认端口80上正在运行的进程

你需要找出哪个进程正在使用端口80,然后决定是否要停止该进程或让你的应用程序使用另一个端口。

Windows:

打开命令提示符并运行以下命令:

netstat -ano | findstr :80

这将显示所有使用端口80的进程。输出中最后一列是进程ID (PID)。

然后你可以使用任务管理器或以下命令来终止该进程:

taskkill /PID <PID> /F

还有一个简单直接的方法,直接关掉程序,重启

Linux/Unix:

打开终端并运行以下命令:

sudo lsof -i :80

这将显示所有使用端口80的进程。你可以使用以下命令来终止该进程:

sudo kill -9 <PID>

macOS:

你可以使用类似于Linux的命令:

sudo lsof -i :80
sudo kill -9 <PID>

2. 修改应用程序端口

如果停止现有进程不是一个选项,你可以将你的Web服务器配置为使用另一个端口(例如8080)。

如果你在使用Spring Boot,可以通过以下方法修改端口:

在application.properties文件中添加:

properties

server.port=8080

在application.yml文件中添加:

yaml

server:
  port: 8080

或者通过编程方式:

java

@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(MyApplication.class);
        app.setDefaultProperties(Collections.singletonMap("server.port", "8080"));
        app.run(args);
    }
}

总结
查找并停止占用端口80的进程。
将你的Web服务器配置为使用另一个端口。
通过以上步骤,你应该能够解决端口冲突问题,让你的Web服务器成功启动。

本文标签: 解决方法ServerfailedDescriptionweb