Skip to content

/errors/spring-boot/port-8080-already-in-use

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

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
Spring Boot
exit code
1
versions
Spring Boot 2.x – 4.x
os
linux, macos, windows

At startup Spring Boot prints Web server failed to start. Port 8080 was already in use. followed by Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. The embedded web server (Tomcat, Jetty or Undertow) cannot bind the port because another process holds it.

Find what holds the port

bash
lsof -i :8080                                   # Linux, macOS
ss -ltnp 'sport = :8080'                        # Linux
netstat -ano | findstr :8080                    # Windows, last column is the PID

Change the port

src/main/resources/application.properties
server.port=8081

Or for one run, without editing files:

bash
java -jar app.jar --server.port=8081
SERVER_PORT=8081 ./mvnw spring-boot:run

server.port=0 picks a random free port; in tests, @SpringBootTest(webEnvironment = RANDOM_PORT) does the same and injects the chosen port with @LocalServerPort.

Sources