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

首个JEE项目无法运行:Tomcat 9.0端口占用问题求助

Fixing Tomcat Port Conflict (8080/8009/8005) in Eclipse Oxygen

Hey there, let's work through this port occupancy issue together—since you've already sorted out the HttpServlet resolution problem, we can dive straight into getting those ports free for your Tomcat 9.0 server. Here are some actionable steps to try:

1. Double-Check You Modified the Correct server.xml File

It's easy to edit the wrong server.xml by accident! Eclipse maintains its own copy of the server config for each server instance, not the one in your Tomcat installation directory. To confirm:

  • In Eclipse's Servers view, right-click your Tomcat 9 server and select Open.
  • Locate and verify the three port entries are updated to unused values:
    • Shutdown port: <Server port="8006" shutdown="SHUTDOWN"> (changed from 8005)
    • HTTP connector: <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/> (changed from 8080)
    • AJP connector: <Connector port="8010" protocol="AJP/1.3" redirectPort="8443"/> (changed from 8009)
  • Save the file before restarting the server.

2. Kill Stuck Tomcat Processes

Sometimes Tomcat processes linger in the background even after you stop the server in Eclipse, holding onto the ports. Here's how to find and end them:

Windows:

  • Open Command Prompt and run:
    netstat -ano | findstr :8080
    netstat -ano | findstr :8009
    netstat -ano | findstr :8005
    
  • Note the PID number next to each port, then open Task Manager → Details tab, find the java.exe/javaw.exe process with that PID, and end it.

Linux/macOS:

  • Open Terminal and run:
    lsof -i :8080  # Replace port number to check others
    
  • Use the PID from the output to kill the process:
    kill -9 <PID>
    

3. Reset Eclipse Server Configuration

Eclipse's publish settings might be overwriting your port changes. Try these steps:

  • Right-click your Tomcat server in the Servers view → Clean.
  • Then right-click again → Publish → Clean.
  • Restart the server and check if the port error is gone.

4. Check for Other Port-Using Applications

These common ports might be grabbed by other software:

  • 8080: Often used by other web servers (Apache, Nginx), proxy tools, or even some IDEs.
  • 8005/8009: Could be used by older Tomcat instances, Java services, or monitoring tools.
    Use the port-check commands from step 2 to identify any non-Tomcat processes using these ports and close them.

5. Create a Fresh Tomcat Server Instance

If all else fails, the existing server instance might have corrupted configs:

  • Delete your current Tomcat server from the Servers view (right-click → Delete).
  • Go to File → New → Server, select Tomcat 9.0, and set up a new instance.
  • Update the port numbers in the new instance's server.xml as before, then reattach your project via Project > Properties > Targeted Runtime.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:15:39