Course – LS – All
announcement - icon

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

>> CHECK OUT THE COURSE

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.

Course – LS – All
announcement - icon

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

>> CHECK OUT THE COURSE

res – REST with Spring (eBook) (everywhere)
Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.