Can't access localhost port in chrome exposed by a Quarkus application in dev mode inseide WSL 2 Windows

Viewed 650

All my applications written in Quarkus/Java can't be accessed in localhost:8000 exposed in dev mode when running inside WSL 2.

    __  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2021-07-27 21:13:15,739 INFO  [io.quarkus] (Quarkus Main Thread) products 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.0.3.Final) started in 1.613s. Listening on: http://localhost:8080
2021-07-27 21:13:15,744 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2021-07-27 21:13:15,745 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [amazon-dynamodb, cdi, resteasy, resteasy-jackson, smallrye-context-propagation, smallrye-openapi, swagger-ui]

I changed the port and nothing changed.

I test run an docker image inside WSL 2 and I can access normally through the chrome.

docker run --publish 8000:8000 amazon/dynamodb-local:1.11.477 -jar DynamoDBLocal.jar -inMemory -sharedDb

I test another application written in vite/vue and can be accessed normally too.

2 Answers

Try setting quarkus.http.host=0.0.0.0 in application.properties

I faced the same issue as this when tried with Quarkus for the first time. I followed the guidance at https://quarkus.io/guides/maven-tooling

Here is a guidance

By default, quarkus:dev sets the debug host to localhost (for security reasons). If you need to change this, for example, to enable debugging on all hosts, you can use the -DdebugHost option like so:

./mvnw compile quarkus:dev -DdebugHost=0.0.0.0

It helps me to solve this issue. Hope this helps other people too.

Related