netbeans is keeping ports after process "stops"

By voodoogiant

I’m playing around with a small java app using RatPack. It’s basically a slightly modified hello-world.

public class App {
    public static void main(String[] args) throws Exception {
        RatpackServer.start(server -> server
                .handlers(chain -> chain
                        .get(ctx -> {
                            HttpClient httpClient = ctx.get(HttpClient.class);
                            httpClient.get(new URI("")).then(response ->
                            //ctx.render("Hello World!");
                        .get(":name", ctx -> ctx.render("Hello " + ctx.getPathTokens().get("name") + "!"))

I’ve noticed when running the app the first time, it all works, but when I click on “Stop the currently executing build” and try running it again, I get:

Exception in thread "main"$NativeIoException: bind() failed: Address already in use

This seems to happen over a variety of web frameworks like Sprint Boot and I recall hitting it in IntelliJ. When I try to kill the process using the port, it kills Netbeans so I need to reopen everything and obviously isn’t a good workflow.

Does anyone know why these ports aren’t being cleaned up? Is there something I can do that actually relinquishes these ports when stopping a run?

Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273