How to fix port 8080 already in use error on Windows and macOS
Getting the “Web server failed to start. Port 8080 was already in use” error? Learn how to identify and kill the process blocking port 8080 on Windows and macOS using simple terminal commands. Fix server startup issues fast and keep your development running smoothly.

Table of Contents
If you're trying to start a web server and see the error:
“Web server failed to start. Port 8080 was already in use.”
You're not alone. This is a common problem when a port your app needs—often 8080
for development—is already being used by another process. Here's what’s happening and how to fix it on Windows and macOS.
🔍 What Does This Error Mean?
Ports are like doors that apps use to communicate over the network. If another program already takes port 8080, your server can’t use it and crashes with that error.
Common culprits:
- Another instance of your app is already running
- A browser-sync tool or frontend server
- Docker, Jenkins, Tomcat, or other dev tools
🛠 How to Fix It on Windows
Step 1: Find the Process Using Port 8080
Open Command Prompt and run:
netstat -ano | findstr :8080
This shows you the PID (Process ID) using port 8080.
Example output:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 12345
Here, 12345
is the PID.
Step 2: Kill the Process
Now run:
taskkill /PID 12345 /F
Replace 12345
with the PID from the previous command. The /F
flag forces the process to terminate.
🛠 How to Fix It on macOS
Step 1: Find the Process Using Port 8080
Open Terminal and run:
lsof -i :8080
This lists processes using port 8080.
Example:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 6789 john 22u IPv6 0x... 0t0 TCP *:http-alt (LISTEN)
Here, 6789
is the PID.
Step 2: Kill the Process
Run:
kill -9 6789
The -9
flag forcefully stops the process.
Alternative Solutions and Best Practices
- Change your server’s port
- Spring Boot: set
server.port
inapplication.properties
/application.yml
, or pass--server.port=9090
on the command line. - Node.js: modify the port constant in your startup script, e.g.
app.listen(process.env.PORT || 3000)
.
- Spring Boot: set
- Graceful shutdown hooks
Implement shutdown hooks in your application so it unbinds cleanly—especially important for Java apps (e.g. using a@PreDestroy
method orRuntime.getRuntime().addShutdownHook(...)
). - Port-checking scripts
Add a lightweight preflight check in your build or startup scripts to detect free ports and either notify you or automatically pick an available port. - Docker port mappings
If you’re running in containers, ensure yourdocker run -p
ordocker-compose.yml
mappings don’t collide with the host ports you need. - Continuous monitoring
Use basic monitoring tools (e.g.,fd://
or simple cron jobs) to alert you when port conflicts arise in staging or production.
✅ After That...
Try restarting your server. If it starts successfully, you’re good.
To avoid the issue in the future:
- Make sure to shut down local servers when you’re done
- Consider changing the port (e.g., to 3000, 5000) if 8080 is often in use
Gopi Gorantala Newsletter
Join the newsletter to receive the latest updates in your inbox.