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

Ubuntu环境运行Java项目报错:Tomcat端口被占用求助

Hey, I know that port conflict error can be super frustrating when you're trying to fire up your Tomcat server in STS on Ubuntu. Let's walk through two reliable ways to fix this:

1. Kill the Process That's Hogging the Ports

This is the quickest fix if you don't need the other process running. Here's how to do it via the terminal:

  • First, find the PID (process ID) of the program using port 8005:
    Run either of these commands:
    sudo lsof -i :8005
    sudo netstat -tulpn | grep :8005
    Look for the number in the PID column of the output—this is what we need to terminate.
  • Kill the process with:
    sudo kill -9 <your-PID-here>
    Replace <your-PID-here> with the actual number you found (e.g., sudo kill -9 1456).
  • Repeat the same steps for port 8080 just to be safe—swap out the port number in the commands above.
2. Change Tomcat's Port Numbers (If You Don't Want to Kill the Other Process)

If the process using those ports is something you need to keep running, just reconfigure Tomcat to use different ports:

  • In STS, locate your Tomcat server in the「Servers」tab. Right-click it and select Open.
  • In the server configuration window, scroll down to the「Ports」section. You'll see:
    • Shutdown port: 8005
    • HTTP/1.1: 8080
  • Change these to unused port numbers—common alternatives are 8006 (for shutdown) and 8081 (for HTTP). Feel free to pick any other ports that aren't in use.
  • Save the configuration, then restart your Tomcat server. It should start up without the port conflict error.

A quick tip: If killing the process doesn't work, double-check if Tomcat might still be running in the background (sometimes it doesn't shut down cleanly). You can also use sudo lsof -i :8080 again to verify the port is free before restarting.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 04:23:33