You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IntelliJ IDEA中Spring Boot HelloWorld启动失败:8080端口占用却查不到进程

Spring Boot 8080端口占用但lsof无输出的问题排查

运行的Spring Boot代码

package com.example.springbootexample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootExampleApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootExampleApplication.class, args);
    }

}

启动时的错误信息

***************************
APPLICATION FAILED TO START
***************************

Description:

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

Action:

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


Process finished with exit code 1

问题

执行lsof -i :8080命令识别占用8080端口的进程,但得到空白输出,请问可能是什么问题?


可能的原因及解决办法

  • 权限不足:lsof默认仅能查看当前用户的进程,系统进程或其他用户的进程需要sudo权限。执行sudo lsof -i :8080再尝试查看。
  • UDP进程占用端口:lsof -i :8080默认只检查TCP端口,若端口被UDP进程占用则无法识别。可以执行lsof -i udp:8080单独检查UDP,或用netstat -anp | grep 8080(Linux)查看所有协议的端口占用情况。
  • 端口处于TIME_WAIT状态:进程已退出,但端口因TCP协议的TIME_WAIT机制暂时被占用,此时lsof无法找到对应进程。可以用ss -tulpn | grep 8080查看这种状态的端口;最直接的解决方式是修改Spring Boot的监听端口,比如在application.properties中添加server.port=8081,或启动时添加参数--server.port=8081。
  • 防火墙/网络工具拦截:部分防火墙、代理软件或网络监控工具可能占用端口但不被lsof识别。可以尝试直接更换端口启动应用,若能正常运行,则说明原端口确实被这类工具占用。
  • Windows系统特殊情况:如果是Windows环境,lsof通常未预装,建议使用netstat -ano | findstr :8080找到占用端口的PID,再执行taskkill /F /PID <PID>强制终止进程;另外需检查WSL子系统是否有进程占用了该端口,需进入WSL环境执行端口排查命令。

内容的提问来源于stack exchange,提问作者Robb1

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 04:40:33