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

前端 未结 22 2515
梦毁少年i
梦毁少年i 2020-12-07 10:49

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 localho

相关标签:
22条回答
  • 2020-12-07 11:05

    Goto Window->Preferences, search for Launching.

    Select the "Terminate and Relaunch while launching" option.

    Press Apply.

    0 讨论(0)
  • 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 !

    0 讨论(0)
  • 2020-12-07 11:09

    No Need to manually start an application every time at time of development to implements changes use 'spring-boot-devtool' maven dependency.

    Automatic Restart : To use the module you simply need to add it as a dependency in your Maven POM:

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
    

    When you have the spring-boot-devtools module included, any classpath file changes will automatically trigger an application restart. We do some tricks to try and keep restarts fast, so for many microservice style applications this technique might be good enough.

    0 讨论(0)
  • 2020-12-07 11:12

    If you got any error on your console by saying, “Embedded servlet container failed to start. Port 8080 was already in use.” Then go to application.properties file and add this property “server.port = 8090”.

    Actually the default port for spring boot is 8080, if you have something else on that port, the above error will occur. So we are asking spring boot to run on other port by adding “server.port = 8090” in application.properties file.

    0 讨论(0)
  • 2020-12-07 11:16

    You can use list open file command and then kill the process like below.

    sudo lsof -t -i tcp:8181 | xargs kill -9
    

    or

    sudo lsof -i tcp:8181
    
    kill -9 PID
    
    0 讨论(0)
  • 2020-12-07 11:17

    Print the list of running processes and try to find the one that says spring in it. Once you find the appropriate process ID (PID), stop the given process.

    ps aux | grep spring
    kill -9 INSERT_PID_HERE
    

    After that, try and run the application again. If you killed the correct process your port should be freed up and you can start the server again.

    0 讨论(0)
提交回复
热议问题