48
votes

I received the following error while attempting to execute a Servlet program in Eclipse Mars EE.

'Starting Tomcat v8.0 Sever at localhost' has encountered a problem.

Port 8080 required by Tomcat v8.0 Server at localhost is already in use. There 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).

What should I do to stop the process? I'm assuming that Tomcat 7 server must be stopped. How shall I do it if my operating system is Windows 8?

Error Screenshot:

error screen shot

19
If you're running tomcat from Eclipse, then check in the Servers view (in the bottom dock) if it's running.Luiggi Mendoza
Run the cmd as administrator for above answers.AryehSa

19 Answers

75
votes

For Ubuntu/Linux

Step 1: Find the process id that is using the port 8080

netstat -lnp | grep 8080
or
ps -aef | grep tomcat

Step 2: Kill the process using process id in above result

kill -9 process_id

For Windows

Step 1: Find the process id

netstat -ano | findstr 8080

Step 2: Open command prompt as administrator and kill the process

taskkill /F /pid 1088

In my case port 8005 was already in use so I used the same above steps.

enter image description here

45
votes

All I had to do was to change the port numbers. enter image description here

  1. Open Eclipse

  2. Go to Servers panel

  3. Right click on Tomcat Server select Open, Overview window will appear.

  4. Open the Portstab. You will get the following:

    • Tomcat adminport

    • HTTP/1.1

    • AJP/1.3

  5. I changed the port number of HTTP/1.1 (i.e. to 8081)

  6. You might have to also change the port of Tomcat adminport (i.e. to 8006) and of AJP/1.3 (i.e. to 8010).

  7. Access your app in the browser at http://localhost:8081/...

22
votes

If you want to regain the 8080 port number you do so by opening the task manager and then process tab, right click java.exe process and click on end process as shown in image attached.

screen shot

19
votes

In case of MAC users, go to Terminal and do the following

lsof -i :8080 //returns the PID (process id) that runs on port 8080
kill 1234 //kill the process using PID (used dummy PID here)
lsof -i :8443
kill 4321

8080 is HTTP port and 8443 is HTTPS port, by default.

15
votes
netstat -ano | findstr 8080
taskkill /pid 21424 /F

execute the above command in command prompt first command will find the pid of the processes which are using port 8080 or any other port you are using. And in second command write the pid of instead of 21424.

5
votes

You can solve this in two steps:

STEP 1: Open the Command prompt and type netstat -a -o -f and press enter (the above command will show all the processes running on your machine) https://i.stack.imgur.com/m66JN.png

STEP 2: Type TASKILL /F /PID 4036 (where F stands for force and PID stands for parent Id and 4036 stands for process id of 8080, here I am using some random number) https://i.stack.imgur.com/Co5Tg.png

Few times when you are trying to kill process it will throw an exception telling that access is denied as shown in the above screenshot, at that point of time you are supposed to open command prompt as run as administrator https://i.stack.imgur.com/JwZTv.png

Then come back to eclipse clean the project and then try to run the project

5
votes

Since it is easy to tackle with Command Prompt. Open the CMD and type following.

netstat -aon | find "8080"

If a process uses above port, it should return something output like this.

TCP    xxx.xx.xx.xx:8080      xx.xx.xx.xxx:443      ESTABLISHED     2222

The last column value (2222) is referred to the Process ID (PID).

Just KILL it as follows.

taskkill /F /PID 2222

Now you can start your server.

4
votes

You've another instance of Tomcat already running. You can confirm this by going to http://localhost:8080 in your webbrowser and check if you get the Tomcat default home page or a Tomcat-specific 404 error page. Both are equally valid evidence that Tomcat runs fine; if it didn't, then you would have gotten a browser specific HTTP connection timeout error message.

You need to shutdown it. Go to /bin subfolder of the Tomcat installation folder and execute the shutdown.bat (Windows) or shutdown.sh (Unix) script.

for more help please chech this answer.

3
votes

Open CMD or Powershell in Administrator mode, then run...

netstat -ab

The output should be able to point you in the direction of which process is holding port 8080. Entry may likely be 127.0.0.1:8080 You may still have a running instance of Tomcat at port 8080.

You can either use Stop-Process in PowerShell or taskKill in CMD to stop that process and should be able to execute the program at that point.

3
votes

Solution

You can use the troubleshooting tips below.

Troubleshooting Tip #1

  1. Exit Eclipse

  2. Open a web browser and visit, http://localhost:8080

  3. If you see a "Tomcat" web page then that means Tomcat is running as a Windows service. To stop Tomcat running as a Windows services, open your Windows Control Panel. Find the service "Apache Tomcat" and stop it.

  4. If you don't see a "Tomcat" web page, then stop the appropriate process displayed.

-- Troubleshooting Tip #2 - GUI Option

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

  1. On MS Windows, select Start > All Programs > Accessories > System Tools >Resource Monitor

  2. Expand the Network Tab

  3. Move to the section for Listening Ports

  4. Look in the Port column and scroll to find entry for port 8080

  5. Select the given process and delete/kill the process

  6. Return back to Eclipse and start the Tomcat Server, it should start up now.


Troubleshooting Tip #3 - Command-Line Option

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: (open the CMD command)

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: Return back to Eclipse and start the Tomcat Server, it should start up now.

====

Mac/Linux SOLUTION

Step 0: Exit Eclipse

Step 1: Open a terminal window

Step 2: Enter the following command to find the process id

lsof -i :8080 This will give output of the application that is running on port 8080

Step 3: Enter the following command to kill the process

kill $(lsof -t -i :8080)

Step 4: Return back to Eclipse and start the Tomcat Server, it should start up now.

2
votes

To get rid of this error just click on server tab on eclipse . You will get list of servers as below image (In my case it was tomcat 8 only)

enter image description here

Double click on the respective server. You will get screen as shown below :-

enter image description here

Now change Conflicting port number. In my case I changed 8080 to 8081 (highlighted portion). Save it (ctrl+s) and hence you can start your server now.

2
votes

I have encountered this issue many times. If port 8080 is already in use that means there is any Process ( or it child process) which is using this port

Two Way to Solve this issue:

  1. Change the Port number and this issue will be solved enter image description here

  2. We will find the PID i.e Process Id and then we will kill the process of child process which is using this Port.

Find PID:Process ID (every process has unique PID) c:user>user_name>netstat -o -n -a | findstr 0.0.8080

enter image description here

Now we need to kill this process

cmd ->Run as Admin

C:\Windows\system32>taskkill /F /T /PID 2160

"taskkill /F /T /PID 2160" -> "2160" is the process ID Now your server can use this port 8080

enter image description here

1
votes

you can stop using the shutdown.bat inside tomcat installation directory. Or you may click "stop" button at the servers view of eclipse. To get to the view select Window - Show View - Servers

1
votes

I would suggest to end java.exe or javaw.exe process from task manager and try again. This will not end the entire eclipse application but will free the port.

0
votes

For Ubuntu users with the same problem (e.g. Eclipse crash during debug) do a netstat -a -p | grep 8095 (or any other port number if the Tomcat server), then kill -9 that process.

0
votes

Open below application

C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Apache Tomcat 8.5 Tomcat8

right click on Apache tomcat in system tray and click on stop services

Run your application from eclipse.

http://siddartech.com/apache/apachi-tomcat-server-already-in-use/

0
votes

You can stop the running tomcat server by doing the following steps:

Step 1: go to your tomcat installation path (/bin) in your Windows system

Step 2: open cmd for that bin directory (you can easily do this by typing "cmd" at that directory )

Step 3: Run "Tomcat7.exe stop"

This will stop all running instances of tomcat server and now you can start server from your eclipse IDE.

0
votes

The Way I solved this problem is , Install TCPview go to TCP view and check what ports is Tomcat utilizing there will be few other ports other than 8005,8009,8080 now go to Servers tab in eclipse double click on Tomcatv9.0 server and change port numbers there. This will solve the problem.

0
votes

The thing here is - You have already another tomcat running on port 8080, you need to shut it down. You can do it in several ways. let me tell you 2 simplest ways

  1. Either go to the location where tomcat is installed, go to din directory and execute the shutdown.bat or shutdown.sh

OR

  1. if you are in windows, go to bottom right notification panel of your screen, click on up arrow to see more running services, you will find tomcat here. right click on it and select shutdown... that it.