1. Overview

In this quick tutorial, we're going to learn how to configure the server port on Quarkus applications.

2. Configuring Port

By default, similar to many other Java server applications, Quarkus listens to port 8080. In order to change the default server port, we can use the quarkus.http.port property.

Quarkus reads its configuration properties from various sources. Therefore, we can change the quarkus.http.port property from different sources, as well. For instance, we can make Quarkus listen to port 9000 by adding this to our application.properties:

quarkus.http.port=9000

Now, if we send a request to localhost:9000, the server would return some sort of an HTTP response:

>> curl localhost:9000/hello
Hello RESTEasy

It's also possible to configure the port through Java system properties and -D arguments:

>> mvn compile quarkus:dev -Dquarkus.http.port=9000
// omitted
Listening on: http://localhost:9000

As shown above, the system property is overriding the default port here. In addition to these, we can use environment variables, too:

>> QUARKUS_HTTP_PORT=9000 
>> mvn compile quarkus:dev

Here, we're converting all characters in quarkus.http.port to uppercase and replacing dots with underscores to form the environment variable name.

3. Conclusion

In this short tutorial, we saw a couple of ways to configure the application port in Quarkus.

Generic bottom

Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:

>> CHECK OUT THE COURSE
Generic footer banner
guest
0 Comments
Inline Feedbacks
View all comments