Search code examples
portshutdownhttpserver

What to do if I got stuck in sutting down a server and the port is open?


In my previous question : Error message not going away in Netbeans, why? "java.net.BindException: Address already in use: bind" I suspect I didn't shut down the server properly, so even if the web page from that app is not available after the shutdown, if I tried to re-start the server, it would say port already in use, if it's open why can't I get the page, and if it already down, why the port is not available ? So in that situation, how to close that port ?


Solution

  • After several days of struggle, I finally found the answer : In another class I created a static version of this httpserver class, so whenever the project is compiled and started, the static object will always run and open the port before the non-static object tried to open the same port, so it always says : "The port is in use".