Web server failed to start. Port 9793 was already in use.
文章目录
- [Web server failed to start. Port 9793 was already in use.](#Web server failed to start. Port 9793 was already in use.)
-
- 报错描述
- 报错原因
- 解决方法
-
- [Spring Boot 修改默认端口号](#Spring Boot 修改默认端口号)
- 关闭占用某一端口号的进程
报错描述
Springboot
项目启动控制台报错
bash
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-10-12 09:55:44.462 ERROR 25112 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 9793 was already in use.
Action:
Identify and stop the process that's listening on port 9793 or configure this application to listen on another port.
Disconnected from the target VM, address: '127.0.0.1:3187', transport: 'socket'
Process finished with exit code 1
报错原因
- 端口被占用
解决方法
Spring Boot 修改默认端口号
- 修改
yml
或者properties
配置文件,加上参数:
yaml
# properties 方式
server.port=8014
# yaml 方式
server:
port: 8881
- 注意启动成功后面,后端的端口号变为
8881
了
关闭占用某一端口号的进程
- 使用
cmd
命令查看端口号占用情况,例如查看端口8881
,可以看出进程号为18644
;
bash
netstat -ano | findstr 端口号
关闭该进程
- 方法一:使用任务管理器关闭:菜单栏 -> 右键 - > 任务管理器 -> 详细信息,根据
PID
排序找到PID
为18644
的进程,选择后点击结束任务
- 方法二: 使用命令关闭
r
taskkill -PID 18644 -F