Home
›
Java
›
java.net.BindException: Address already in use — Find the Process and Fix It
Beginner
3 min · November 28, 2026
java.net.BindException: Address already in use — Find the Process and Fix It
BindException: Address already in use means another process is already listening on that port — often the old copy of your own app.
N
Naren
Founder & Principal Engineer
20+ years shipping production Java in banking & fintech. Drawn from code that ran under real load.
Follow
✓ Production
production tested
November 28, 2026
last updated
2,141
articles · all by Naren
VIDEO
Before you start ⏱ 6 min
✓ Basic Java ✓ Basic networking
⚡ Quick Answer
Another process is listening on that port. Linux/macOS: lsof -i :8080 or ss -ltnp 'sport = :8080'. Windows: netstat -ano | findstr :8080, then tasklist /FI "PID eq ". Often it's the old instance of your own app still shutting down. Fix restart scripts: stop, wait for the process to exit, then start. Or kill the stale process, or run on another port (server.port=8081).
✦ Definition ~90s read
What is java.net.BindException?
java.net.BindException: Address already in use is thrown when a server socket tries to bind to a port that another process is already listening on. Spring Boot reports it as 'Web server failed to start. Port 8080 was already in use.'
★ A port is a single socket on the wall.
Plain-English First
A port is a single socket on the wall. One plug at a time. If the old plug is still in, the new one can't go in.
A restart script started the new orders-api before the old one had finished stopping. Port 8080 was still taken.
Find the Process Identify who is listening on the port before changing anything.
lsof -i :8080
# java 4211 app LISTEN
# Windows
netstat -ano | findstr :8080
tasklist /FI "PID eq 4211" 🎯 Key Takeaway
Know the holder first.
Fix the Restart Stop, wait for the process to exit, then start.
kill "$PID"
while kill -0 "$PID" 2 >/dev/null ; do sleep 1 ; done
./start.sh 🎯 Key Takeaway
Never overlap instances.
Or Change the Port If another application legitimately uses the port, run yours elsewhere.
application.properties PROPERTIES
Copy 🎯 Key Takeaway
server.port.
● Production incident POST-MORTEM severity: high
The Restart That Overlapped Symptom
Web server failed to start. Port 8080 was already in use.
Assumption
The team suspected another application had grabbed the port.
Root cause
restart.sh sent stop and immediately started the new instance; the old one needed ~8 s to shut down.
Fix
The script now waits for the old PID to exit before starting.
Key lesson
One listener per port. Wait for exit before start. Find the holder with lsof/netstat.
Production debug guide Who holds it? 3 entries
→
Fix
netstat -ano | findstr :8080
Symptom · 03
Only during restarts
→
Fix
Overlapping instances: wait for exit.
⚙ Quick Reference
3 commands from this guide
File Command / Code Purpose find.sh lsof -i :8080 Find the Process restart.sh kill "$PID" Fix the Restart application.properties server.port=8081 Or Change the Port
Key takeaways 2 lsof / netstat to find it.
Common mistakes to avoid 2 patterns × Starting before the old process exits Symptom
Bind fails on every restart.
Fix
Wait for exit.
× Killing without checking Symptom
Stopped someone else's service.
Fix
Identify the PID's owner first.
INTERVIEW PREP · PRACTICE MODE
Interview Questions on This Topic
Practice
List View
Q01 JUNIOR
What causes BindException: Address already in use?
Q01 of 01 JUNIOR
What causes BindException: Address already in use?
ANSWER
Another process is already listening on that address and port.
01
What causes BindException: Address already in use?
JUNIOR
FAQ · 2 QUESTIONS
Frequently Asked Questions
01
How do I free port 8080? Find the PID with lsof or netstat and stop that process.
Was this helpful? 👍 Yes 👎 No
02
Port 8080 was already in use Spring Boot? Same error; find the process or set server.port.
Was this helpful? 👍 Yes 👎 No
N
Naren
Founder & Principal Engineer
20+ years shipping production Java in banking & fintech. Drawn from code that ran under real load.
Follow
✓ Verified
production tested
November 28, 2026
last updated
2,141
articles · all by Naren
🔥
That's Exceptions. Mark it forged?
3 min read · try the examples if you haven't
✓ Mark as read · go to ADB Device Unauthorized Fix →
Save for later