Address localhost 8080 is already in use как исправить

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 ...

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:Usersusername>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:Usersusername>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.

In this post, We will try to understand the Web server failed to start Port 8080 was already in use error and how to fix it.

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

In the network, an IP address identifies each machine. Similarly, The network port identifies the application or process running on a machine. When an application wants to use a port, the OS binds one. However, when multiple applications want to use the same port, there is a port clash.

In our case, port 8080 was already being used by another application and hence the web server failed to start. Usually, you would get this error in the case of ports 8080, 8081, 9090, etc. So in general, If you get a “port 8080 was already in use” error, then it is certain that another application is already using that port.

This is most likely due to bad configuration from your end, running the application multiple times, or not using proper startup and shutdown scripts.

Fix for Web server failed to start

As we know, The cause is that another process is running on the same port. To solve this, you have two options.

  1. Try to run the application on a port other than 8080.
  2. Identify and stop the process running on that specific port

Option 1: Run your web server on a different port

Most of the application frameworks provide options to change the ports they listen to. For instance, you can change the application port of a spring boot application in the following ways.

You can provide a server.port configuration with a different port number in the application.properties file.

server.port=9090

Code language: Properties (properties)

You can also pass the port number as an application parameter.

java - jar my-server.jar --server.port=9090

Code language: Bash (bash)

Or a JVM parameter.

java - jar -Dserver.port=9090 my-server.jar

Code language: Bash (bash)

This way, The application starts on a different port. Thus the “Web server failed to start. Port 8080 was already in use” error is avoided.

There is a detailed post on how to change the default tomcat port number in 5 different ways. You can also find more details on how the spring boot configuration works in their official documentation.

Option 2: Kill the server running on port 8080

Sometimes, the other process is just an old instance of the same application or an application that you don’t want to run. In these cases, it is best to identify and kill them so that you can start your application on that specific port. To do that you need to first identify the process. Second, you need to kill it.

Say you got the error for running on port 8080. Then you should use the below command for identifying the process or service.

Finding and killing process running on port 8080 on Linux/Mac

One of the following commands should give the process ID (PID) of the application or service running on port 8080.

sudo lsof -n -i :8080 | grep LISTEN sudo netstat -nlp | grep :8080 sudo ss -lptn 'sport = :8080'

Code language: Bash (bash)
fix for Web server failed to start. Port 8080 was already in use
python http server running on port 8080 with PID 25321

With the PID from the above output, you can kill the process using the following commands.

#to kill process gracefully kill -15 25321

Code language: Bash (bash)

or

#To force kill a process kill -9 25321

Code language: Bash (bash)

By killing the process occupying the port on 8080, the web server can start without any problems.

For your use, replace the process id with the process id that you found on your machine.

Finding and killing process running on port 8080 on windows

Similarly, You can run the following command to identify a process running on a port in windows.

netstat -ona | findstr :8080 | findstr LISTENING

Code language: Bash (bash)
command to find process running on port 8080 in windows
process 23928 listening on port 8080

Once you get hold of the process id, you can use the following command to kill it.

taskkill /PID 25321 /F

Code language: Bash (bash)

As I said earlier, for your machine, the process ID may be different. The /F is there to force kill the process. In most cases, you will not require this flag.

Conclusion

So we learned ports work and how to solve “Port 8080 was already in use” errors on application startup. If you liked this article, then you might like to read about the following titles.

The spring boot Web server failed to start. Port 8080 was already in use. error occurs because port 8080 is already configured with another application, or port 8080 has not been released yet. The spring boot application is trying to configure port 8080 to start a web server. Since the port can not be used, this error is thrown. The action is Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port.

The Spring boot application uses tomcat as a web server. The default tomcat port is 8080. If any application listens to port 8080 and if you start the spring boot application, this exception is thrown as tomcat can not use port 8080.

Exception

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.

Root Cause

Tomcat is running on port 8080. Spring boot application uses tomcat as the default web server. The port 8080 is currently being used by the application and tomcat is trying to listen to port 8080. A different application may be used for port 8080. Or the current application is already running. You ‘re trying to get started again.

Solution 1

You’ve already started and running the spring boot application. Now you’re trying to run the spring boot application again. Stop all the instance or restart your IDE.

You may be running an instance on a terminal or command line, or run as a service. Now you’re trying to get your IDE started again. Check all the applications that can use port 8080 and make sure the application is not started.

Solution 2

Some external applications already use port 8080. Check the running application in the task manager, stop the application that listen to port 8080.

The running application can be identified by the process commands. Identify the process that uses port 8080. Stop the application so that port 8080 is released to the other application to be used. Run the command below in linux to find the application that uses port 8080, and then kill the process if you want to stop it.

ps -ef | grep 8080

kill -9 <process id>

Solution 3

Some of the valid applications are running the default port. The application that may be used for other purposes can not be stopped. The other option is to change the default listening port in the application.properties and start the spring boot application again.

application.properties

server.port=80

How to create simple Spring Boot Application with Main method

Dmitry, спасибо! Сейчас прочитаю, попробую что-нибудь сделать. Судя по гуглу такая проблема не только у меня, у людей на WinXP тоже самое бывает, но инфа старая — баг в багтреке от 2013 году и должен был быть уже устранен. Попробую с зависимостями (библиотеками) проекта поиграть. Буду держать в курсе, что получилось из этого.

Добавлено через 4 часа 32 минуты
Похоже нашел в чем проблема, но пока до конца не разобрался. Проблема не в ОС, а в настройках сервера Tomcat в среде разработки, получается что сборщик проектов Maven дважды пытается деплоить варник. Решается настройкой Run/Debug Configuration (убераеться все лишнее, только clean, package и вперед).

Добавлено через 1 час 13 минут
Тему можно удалять. Хотя такие проблемы случаются и нашел кучу вариантов из-за чего такое может быть, в моем случае все оказалось банально. Баг в Tomcat 8.5.13 (https://bz.apache.org/bugzilla… i?id=60949) и тут два варианта либо дожидаться 8.5.14, либо ставить другую проверенную уже, более раннюю версию кота Тома

I am new to intelij idea

I started debugging an application that was previously being written inside eclipse.

I configured the run configurations to startup tomcat and open chrome for the view.

However, after several runs the following happens:

  1. the source files stop being updated
  2. intelij claims localhost port is already busy

how do i stop the localhost run from intelij when the stop option (shift+f2) is grayed out
and how do i make the sources be updated.

it seems only a computer reboot fixes this problem right now
i obviously cant reboot my computer once every 10 minutes.

Du-Lacoste's user avatar

Du-Lacoste

10.7k2 gold badges64 silver badges50 bronze badges

asked Apr 28, 2014 at 20:05

Lena Bru's user avatar

1

If none of the above mentioned ways did not work for you, try this.

Open the Command Prompt and type following.

netstat -aon | find "1099"

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

TCP    xxx.xx.xx.xx:1099      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 start debugging.

answered Apr 22, 2019 at 2:23

Du-Lacoste's user avatar

Du-LacosteDu-Lacoste

10.7k2 gold badges64 silver badges50 bronze badges

InteliJ claims localhost port is already busy => This means that the program that opened this listening port is still running. Now, it looks like you are starting the program from IntelliJ, but then it keeps running after IntelliJ disconnects from it. Do find if that is still the case.

answered Apr 29, 2014 at 6:32

Tassos Bassoukos's user avatar

Tassos BassoukosTassos Bassoukos

16k2 gold badges36 silver badges40 bronze badges

1

If the necessary port (for tomcat 8080 for example) is busy outside of eclipse or IDEA, you can see use Tcpview application which shows which process which port use (you can just kill them if they are not so necessary). It seams files are read only, or IDEA don’t recognize them as java files right click on source root and select Murk Directory As->Source Root. Try these steps and if you help more questions you are welcome.

answered Apr 29, 2014 at 6:45

Ashot Karakhanyan's user avatar

I am new to intelij idea

I started debugging an application that was previously being written inside eclipse.

I configured the run configurations to startup tomcat and open chrome for the view.

However, after several runs the following happens:

  1. the source files stop being updated
  2. intelij claims localhost port is already busy

how do i stop the localhost run from intelij when the stop option (shift+f2) is grayed out
and how do i make the sources be updated.

it seems only a computer reboot fixes this problem right now
i obviously cant reboot my computer once every 10 minutes.

Du-Lacoste's user avatar

Du-Lacoste

10.7k2 gold badges64 silver badges50 bronze badges

asked Apr 28, 2014 at 20:05

Lena Bru's user avatar

1

If none of the above mentioned ways did not work for you, try this.

Open the Command Prompt and type following.

netstat -aon | find "1099"

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

TCP    xxx.xx.xx.xx:1099      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 start debugging.

answered Apr 22, 2019 at 2:23

Du-Lacoste's user avatar

Du-LacosteDu-Lacoste

10.7k2 gold badges64 silver badges50 bronze badges

InteliJ claims localhost port is already busy => This means that the program that opened this listening port is still running. Now, it looks like you are starting the program from IntelliJ, but then it keeps running after IntelliJ disconnects from it. Do find if that is still the case.

answered Apr 29, 2014 at 6:32

Tassos Bassoukos's user avatar

Tassos BassoukosTassos Bassoukos

16k2 gold badges36 silver badges40 bronze badges

1

If the necessary port (for tomcat 8080 for example) is busy outside of eclipse or IDEA, you can see use Tcpview application which shows which process which port use (you can just kill them if they are not so necessary). It seams files are read only, or IDEA don’t recognize them as java files right click on source root and select Murk Directory As->Source Root. Try these steps and if you help more questions you are welcome.

answered Apr 29, 2014 at 6:45

Ashot Karakhanyan's user avatar

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Addon sauerland requires addon chernarus как исправить
  • Addon file cache missing redownloading downloaded error failed to read the downloaded file
  • Additionally a 503 service unavailable error
  • Additional signup required unable to get education profile код ошибки 41 сферум
  • Additional information woocommerce как изменить

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии