How can I configure the port a Quarkus application runs on?
Asked Answered
A

4

15

I would like my Quarkus application to run on a port other than the default. How can I accomplish that?

Astound answered 7/3, 2019 at 12:18 Comment(0)
A
31

The Quarkus configuration property to be used is quarkus.http.port (the default value is 8080). If this property is set in application.properties then that value will be used.

The property can also be overridden at runtime as follows:

When running a Quarkus application in JVM mode you can set the port using the quarkus.http.port System property. For example:

java -Dquarkus.http.port=8081 -jar example-runner.java

The same property applies to GraalVM Native Mode images. For example:

./example-runner -Dquarkus.http.port=8081
Astound answered 7/3, 2019 at 12:19 Comment(6)
Also if you run this app inside a container remember to add: -Dquarkus.http.host=0.0.0.0 to access from outside.Failure
@HectorVenturaReyes that is true for 0.11.0, but should not be necessary for newer versionsAstound
@Astound where is the full list of quarkus properties?Makeup
@Tuelho There isn't one yet (but there are plans to create it). You would have to look at the source code of *Config classes, like github.com/quarkusio/quarkus/blob/0.14.0/extensions/undertow/…Astound
And if you need to override the default test port use: quarkus.http.test-port=8888 I was having issues running tests on windows.Ozonide
The following command also works: mvn -Dquarkus.http.port=8081 quarkus:devHalfwit
E
6

To complement geoand’s answer, you can use the same property for mvn quarkus:dev. Unfortunately you cannot directly set it in a profile in ~/.m2/settings.xml to avoid the need to type it each time (for example because Microk8s binds 8080), but you can set it via jvm.args:

<profiles>
    <profile>
        <id>microk8s-quarkus-dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <jvm.args>-Dquarkus.http.port=8090</jvm.args>
        </properties>
    </profile>
</profiles>

Alternately, you could configure this in project sources:

echo '%dev.quarkus.http.port=8090' >> src/main/resources/application.properties

though this would not be shared across projects, and might be unwanted by other developers of the same project.

Ernestoernestus answered 12/8, 2019 at 15:58 Comment(0)
C
4

You can use <projhome>/resources/application.properties to configure the port.

For example

quarkus.http.port=8080
%dev.quarkus.http.port=8811
%test.quarkus.http.port=7711
%server.quarkus.http.port=6611

Here dev, test, and server refer to the profiles.

You can run them as below

$ mvn compile quarkus:dev -- port 8811 will be used

$ mvn -Dquarkus-profile=server compile quarkus:dev -- port 6611 will be used

Century answered 30/9, 2021 at 0:46 Comment(0)
E
1

To change the default port for a Quarkus application, you would indeed add the following line to your application.properties file:

quarkus.http.port=8001

This line instructs Quarkus to use port 8001 instead of the default port 8080 for HTTP communication.

Eschalot answered 8/2 at 10:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.