
You run your Spring Boot application — maybe for the tenth time today — and instead of the usual startup banner, you get a wall of red text ending in:
***************************
APPLICATION FAILED TO START
***************************
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.
It’s harmless, it’s common, and it’s almost always fixed in under a minute. Something else on your machine — very often another instance of your own app you forgot to stop — is already sitting on port 8080.
Why This Happens
1. You Already Have Another Instance Running
The most common cause by far. You ran the app from your IDE, it’s still running in the background, and now you’ve started a second instance — or you ran it from the terminal and the IDE at the same time.
2. A Docker Container Is Using the Port
If you have a container mapped to 8080:8080 — a database admin UI, another microservice, or a leftover container from a previous session — it will hold onto port 8080 even if you’ve completely forgotten about it.
3. A Zombie Java Process
Sometimes a previous run of your app doesn’t shut down cleanly, especially after an IDE crash or force-stop. The JVM process lingers in the background, still bound to the port.
4. IDE Re-Run Without Stopping the Previous Session
IntelliJ and Eclipse allow you to hit Run again while a previous run configuration is still active. Some setups auto-stop the old one; others don’t — especially with Spring Boot DevTools enabled.
Fix Methods
Method 1: Find and Kill the Process
Windows (Command Prompt):
netstat -ano | findstr :8080
This returns a line ending in the PID (process ID), for example:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 14328
Kill it with:
taskkill /PID 14328 /F
Linux / macOS:
lsof -i :8080
Note the PID from the output, then:
kill -9 <PID>
Or as a one-liner:
kill -9 $(lsof -t -i:8080)
Method 2: Change the Port in application.properties
If you don’t want to hunt down processes — or you genuinely need both apps running simultaneously — just change the port:
# application.properties
server.port=8081
Or in application.yml:
server:
port: 8081
You can also pass it as a command-line argument without touching any config files, great for quick local testing:
java -jar app.jar --server.port=8081
Method 3: Check Running Docker Containers
docker ps
Look through the PORTS column for anything mapped to 8080. Stop a specific container with:
docker stop <container_id>
If you’re not sure which container it is and don’t mind stopping them all:
docker stop $(docker ps -q)
Best Practice: Prevent Port Conflicts Long-Term
Use Environment-Based Ports
Hardcoding server.port=8080 across all environments is what causes most collisions in the first place. Externalize it instead:
server.port=${APP_PORT:8080}
This uses 8080 as a default but lets you override it per environment:
APP_PORT=8085 java -jar app.jar
Use Spring Profiles for Multi-Service Local Development
If you run several Spring Boot microservices locally, give each one its own profile-specific port so they never compete:
# application-service-a.properties
server.port=8081
# application-service-b.properties
server.port=8082
java -jar service-a.jar --spring.profiles.active=service-a
Conclusion
Port 8080 conflicts are almost never a sign of a broken application — they’re a sign that something else got there first. Check for lingering processes, check Docker, and if you’re tired of the whole thing, give your app a dedicated port via configuration. It takes thirty seconds and you’ll never think about it again.
