简体   繁体   中英

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

I am trying to develope a webapp using spring boot in STS. While running my app i am getting

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.

I have tried to close the application for port 8080. I found the PID for the port and terminated it using

taskkill /F /PID pidname

I restarted the STS and tried to run again but its throwing the same error.

If port is acquired by some OS thread, it would be a bit tricky to stop it. Although it's not always great solution, but if you still want to continue with your development without any issue you can use this alternative solution (as you are in development environment).

Here is another thing you can use. You can replace the default port for Spring Boot server to some other port number.

For server port the property is server.port .

If you are using application.properties file:

server.port=8081

It will start server on port 8081.

Similarly, you can do the same if using an application.yml file:

server:
  port : 8081

Each file is loaded by Spring Boot if placed in the src/main/resources directory of a Maven application.

Your only other option (beside making port 8080 available or using another port for spring boot) is running the application in docker:

Create a Dockerfile in your application directory

FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Run in terminal

sudo docker build -t spring-app . && docker run -d -p 8080:8080 -t springapp

(This assumes you have docker installed, please install it if you don't have it)

Are you sure that you stopped your Spring Boot Application in STS and restarted? If not, try it and check.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM