Several ports (8005, 8080, 8009) required by Tomca

2019-01-01 07:41发布

I'm getting the following error when I try to run a simple JSP program on Tomcat in Eclipse.

Several ports (8005, 8080, 8009) required by Tomcat v6.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).

How is this caused and how can I solve it?

30条回答
流年柔荑漫光年
2楼-- · 2019-01-01 08:14

Steps to free port which is already used to run tomcat server in Eclipse

For example , suppose 8080 port is used , we need to make free 8080 to run tomcat

Step 1:

C:\Users\username>netstat -o -n -a | findstr 0.0:8080

TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 3116

Now , we can see that LISTENING port is 3116 for 8080 ,

We need to kill 3116 now

Step 2:-

C:\Users\username>taskkill /F /PID 3116

Step 3: Go to Eclipse and start Server , it will run

查看更多
残风、尘缘若梦
3楼-- · 2019-01-01 08:15

The problem often arises when Apache Tomcat fails to terminate, properly, even though a shutdown instruction was sent. In my case, using Tomcat 8, this happens with annoying regularity. Luckily, you can use Windows PowerShell and the netstat command to create a simple script to kill the process.

The following PowerShell script will parse the output from netstat to find any process that is listening on 127.0.0.1:8005, extract its PID and then kill that process:

netstat -a -o -n `
 | select -skip 4 `
 | % {$a = $_ -split ' {3,}'; New-Object 'PSObject' -Property @{Original=$_;Fields=$a}} `
 | ? {$_.Fields[1] -match '127\.0\.0\.1\:8005$'} `
 | % {Write-Host "Killing PID" $_.Fields[4] "..."; taskkill /F /PID $_.Fields[4] }

If your server.xml configures Tomcat to use a different port or IP, edit the regular expression on the script's fourth line accordingly.

Finally, I should point out that the situation is better on Linux because you can instruct Tomcat to save its PID to a file at startup-time and use a switch to force the shutdown, later - the shutdown script for 'nix systems already features the ability to kill the process and the sleuth-work with netstat is not required.

查看更多
千与千寻千般痛.
4楼-- · 2019-01-01 08:16

Several ports (8005, 8080, 8009) required by Tomcat vX.X Server at localhost are already in use

To check whether another instance of Tomcat already running or some other process is using the ports you can use:

netstat -b -a in command prompt for windows. This lists the ports in use and gives you the executable that's using each one. You need to be in the admin group to do this.

You might get something like this:

TCP 192.168.0.1:8009 192.168.0.1:0 LISTENING 196 [Tomcat7.exe]

TCP 192.168.0.1:8080 192.168.0.1:0 LISTENING 196 [Tomcat7.exe]

TCP 192.168.0.1:8005 192.168.0.1:0 LISTENING 196 [Tomcat7.exe]

Open task manager Ctrl+Shift+Esc, and kill Tomcat7.exe or any other process using these ports.

查看更多
余生无你
5楼-- · 2019-01-01 08:17

If the above issue occurs in Windows 7 or 10 based OS, the problem occurs because Tomcat is running as Windows Service. To stop Tomcat running as Windows Services, Open Windows Control Panel. Find the service "Apache Tomcat" and Stop it. The Another way is to kill the process running on port 8080 using cmd.

Open cmd running it as administrator.

  1. C:\users\username>netstat -o -n -a|findstr 0.0:8080
  2. TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 2160.
  3. The above 2160 is process id of process running on port 8080 and kill that process using the following command
    C:\users\username>taskkill /F /PID 2160
  4. Go to IDE and start Server, it will run
查看更多
余生请多指教
6楼-- · 2019-01-01 08:18

On Eclipse make a raw delete of Tomcat configuration folder under project "Servers". I tried it as last hope and it worked.

查看更多
笑指拈花
7楼-- · 2019-01-01 08:18

In case of windows, I experienced a new stuff... stopping tomcat from /bin folder will immediately not releasing the port 8080. It takes around 5-10 mins to release the port. After 10 mins again if i try to run my project Run-> Run on server .. it allows to run.

I'm unsure whether my understanding is correct!

查看更多
登录 后发表回答