quarkus-quinoa icon indicating copy to clipboard operation
quarkus-quinoa copied to clipboard

Angular "ng serve" is not answering on http://localhost:4200 from Java

Open ia3andy opened this issue 3 years ago • 1 comments

This is referenced there: https://github.com/angular/angular-cli/issues/2375

For some obscure reason, the workaround is to replace ng serve by ng serve --host 0.0.0.0 to make it work.

To reproduce, start ng serve then try this script with jbang:

///usr/bin/env jbang "$0" "$@" ; exit $?


import static java.lang.System.*;
import java.io.*;
import java.net.*;

public class MyTest {

    public static void main(String... args) {
         try {
            URL url = new URL("http://localhost:4200");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(2000);
            connection.setReadTimeout(2000);
            connection.connect();
            int code = connection.getResponseCode();
            System.out.println(code);

        } catch (ConnectException | SocketTimeoutException e) {
            e.printStackTrace();
        } catch (IOException e) {
            throw new RuntimeException("Error while checking if package manager dev server is up", e);
        }
    }
}

ia3andy avatar Apr 20 '22 14:04 ia3andy

I just found the same problem using plain webpack on the patternfly react seed: https://github.com/patternfly/patternfly-react-seed.git

The same fix works: 0.0.0.0 as HOST.

ia3andy avatar May 05 '22 06:05 ia3andy

@ia3andy did you just fix this issue with your new IPV4 vs 6 fix?

melloware avatar Jun 14 '23 15:06 melloware

Right :)

ia3andy avatar Jun 14 '23 17:06 ia3andy