8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE

250,925

Solution 1

It sometimes happen even when we stop running processes in IDE with help of Red button , we continue to get same error.

It was resolved with following steps,

  1. Check what processes are running at available ports

    netstat -ao |find /i "listening"

    We get following

    TCP 0.0.0.0:7981 machinename:0 LISTENING 2428 TCP 0.0.0.0:7982 machinename:0 LISTENING 2428 TCP 0.0.0.0:8080 machinename:0 LISTENING 12704 TCP 0.0.0.0:8500 machinename:0 LISTENING 2428

    i.e. Port Numbers and what Process Id they are listening to

  2. Stop process running at your port number(In this case it is 8080 & Process Id is 12704)

    Taskkill /F /IM 12704 (Note: Mention correct Process Id)

For more information follow these links Link1 and Link2.

My Issue was resolved with this, Hope this helps !

Solution 2

For Mac users(OS X El Capitan):

You need to kill the port that localhost:8080 is running on.
To do this, you need to do two commands in the terminal :N

sudo lsof -i tcp:8080

kill -15 PID 

NB! PID IS A NUMBER PROVIDED BY THE FIRST COMMAND.

The first command gives you the PID for the localhost:8080.
Replace the PID in the second command with the PID that the first command gives you to kill the process running on localhost:8080.

Solution 3

You have to stop the current process and run your new one. In Eclipse, you can press this button to ReLaunch your application: enter image description here

Solution 4

The reason is one servlet container is already running on port 8080 and you are trying to run another one on port 8080.

    1. Check what processes are running at available ports.

      • For Windows :

      • netstat -ao |find /i "listening" Image01

      OR

      • netstat -ano | find "8080" (Note: 8080 is port fail to start) Image02
    1. Now try to reLaunch or stop your application.

      • To relaunch: you can press this button

    Image03

    • To stop in windows:

    Taskkill /F /IM 6592 Note: Mention correct Process Id

    Image04

    right click on the console and select terminate/disconnect all

    • Go to Task Manager and end Java(tm) platform se binary

    click here to view image

    What is java(tm) platform se binary(Search in google

Another option is :

Go to application.properties file set server.port=0. This will cause Spring Boot to use a random free port every time it starts.

Solution 5

In my case, the error occurred as the application was unable to access the keystore for ssl.

Starting the application as root user fixed the issue.

Share:
250,925
milan.latinovic
Author by

milan.latinovic

10+ years of software engineering Specialities: Software development, PHP, Java, REST API, OpenApi, MySQL, Microservices, Integrations, Interfaces, Interoperability, Processes, Solution Architecture, LDAP, Azure. Interested in optimization topics and in software and architecture design patterns. Bike driving, swimming, coding, hanging out. Get in touch: milanlatinovic.com

Updated on December 15, 2021

Comments

  • milan.latinovic
    milan.latinovic over 2 years

    I have strange thing when I try to modify Spring project inside my Spring Tool Suite. On the first load (deploy) everything is fine, application compiles and runs on localhost:8080

    When I change something inside code and try to redeploy it (Run it again - Run As Spring Boot App) I get error message

    *************************** APPLICATION FAILED TO START


    Description:

    The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.

    Action:

    Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.

    2016-10-19 00:01:22.615 INFO 10988 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3023df74: startup date [Wed Oct 19 00:01:19 CEST 2016]; root of context hierarchy 2016-10-19 00:01:22.616 INFO 10988 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown

    If I shutdown process on that port manually everything works fine again, but this can't be right way of redeploying Spring app. Am I doing something wrong here?

    I'm using :: Spring Boot :: (v1.4.1.RELEASE)

    P.S. I'm aware that I can setup some kind of hot-swap mechanism to have automatic reload of page after I change code, but for now I would like to resolve this issue first.

    Thanks for any kind of help or info.

  • milan.latinovic
    milan.latinovic over 7 years
    true, I actually found Relaunch button inside dashboard. I was expecting Run As to somehow automatically remove previous servlet container from 8080 and run new one, but I guess it doesn't work that way. In any case, there is button inside STS, and it works now.
  • amritanshu
    amritanshu over 6 years
    yes and it does shows up in the error logs as well!
  • FullStackDeveloper
    FullStackDeveloper over 6 years
    Your solution works. I just want to add how we set it to listen on another port. Just put server.port=9000 in your application.properties
  • Dean
    Dean over 6 years
    I found this useful because after closing STS, sometimes the website does not close its local tc server. No amount of clicking red squares helped; additionally, launching from STS and stopping again still did not kill the server sometimes.
  • Carlos Cavero
    Carlos Cavero over 6 years
    Thanks man! I wasted a lot of time because I did not read the whole log! I was going crazy checking if some process was still alive
  • Registered User
    Registered User over 6 years
    @CarlosCavero With spring boot, I have noticed that we really need to go through the whole log to notice what the issue might be. Generally, there are many reasons why the last error message might show up, and searching online only for the last message does not show satisfactory results :)
  • Carlos Cavero
    Carlos Cavero over 6 years
    Exactly! That's why I upvoted your answer. Looking for other reasons than the typical port busy (even I restarted the pc). Ignore your intuition and do not trust the last message :)
  • mohan krishna
    mohan krishna about 6 years
    change the port number to something else like 8091 if its not working
  • LittleLittleQ
    LittleLittleQ about 5 years
    lsof -nP +c 15 | grep LISTEN for macOS
  • Gayan
    Gayan over 4 years
    Some might need run sudo apt install htop
  • Fayza Nawaz
    Fayza Nawaz almost 4 years
    there is no second command. apparently the answer was edited (partially) however, i checked using the history and it worked for me., thanks.
  • Shubham Chopra
    Shubham Chopra over 3 years
    If the red button is not activated you need to right click on the console and select terminate/disconnect all.
  • Sam
    Sam over 3 years
    Some of the eclipse doesn't have this option. If unable to find then just try this Window->Preferences, search for Launching. Select the "Terminate and Relaunch while launching" option. and apply
  • jsog
    jsog over 3 years
    @FayzaNawaz I have changed it back to the original based on your comment. Thank you
  • amine
    amine over 2 years
    Thanks, I used "server.port=0", because I got the message "Port already in use" for all ports I wrote even if they are not in use.