Jetty – How to solve java.net.BindException: Address already in use: bind
We will hit this error when we are trying to start a Java web app or start Jetty server. Basically, this error lets us know that there is a process that is using port 8080
. And this is also the port that Jetty uses port it by default, therefore this is the cause of the problem.
In order to fix this problem, we simply find out which PROCESS is using port 8080
and kill it immediately.
Here is step by step how to do this:
1. Checking network and Internet connections
- Windows:
netstat -aon | find "8080"
- Linux:
netstat -tulpn | grep '8080'
You will get something like this:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 15684
TCP [::]:8080 [::]:0 LISTENING 15684
...
2. Checking which process id has binded to your port
In the above, the process id that has binded to 8080 port is 15684
.
3. Kill the process
- Windows:
taskkill /f /pid 15684
- Linux:
kill -9 15684
You are done! Let’s try again :]