简体   繁体   中英

"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?

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

谢谢DaniuNickAth ,正如你所说的问题是错误的命令 - ctrl+z 只是暂停了进程,而 ctrl+c 杀死了它,这里工作正常。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM