Rolf
Rolf

Reputation: 99

"BindException: Address already in use" after an application is quited

I am learning to code microservices in VertX on my new MacBook, and here is the issue:

  1. I wrote some code, which builds http server at localhost, port 8080, and named it MyMicroservice.
  2. I ran it (succesfully) with command java -jar MyMicroservice.
  3. I quit it using ctrl+z.
  4. I try to run it again, in the same way - and I get: [INFO] SEVERE: java.net.BindException: Address already in use

How to avoid it? I can handle it with restarting my computer, but I believe there are is some faster approach?

Upvotes: 0

Views: 749

Answers (2)

Stephen L.
Stephen L.

Reputation: 64

On Windows, to find and kill the process that is listening to a specified port (often 8080)

  1. Open the Command Prompt as Administrator

  2. netstat -anbo | findstr "8080"

Note: must use double quotes

The last field in the response line is the process id (pid). Stop the process with

  1. taskkill /F /PID pid

Upvotes: 1

Rolf
Rolf

Reputation: 99

Thanks Daniu and NickAth, as you said the problem was wrong command - ctrl+z just suspended the process, and ctrl+c kills it, what works here fine.

Upvotes: 0

Related Questions