Change Jetty Server Running Port ( 2026 Update)

Update (September 2026): This post was originally written in May 2012 and the original content is preserved below, with the current instructions for 2026 added after it.

Jetty is one one of the best development server which I have ever used. It is easy to work with jetty server and its light weight

Here I am going to show how to change jetty server running port.  Jetty server default running port is 8080.
The original 2012 instructions 

Port with Maven: 

  1.  Command line:
  2.          For starting jetty server we are using mvn jetty:run command. We can change the port jetty server running by passing run time argument to it.

             mvn -Djetty.port=80 jetty:run


  3.  Using pom.xml

                By changing jetty plugin system properties as below, you can change the jetty running port.
<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <configuration>
        <stopPort>9966</stopPort>
        <stopKey>foo</stopKey>
        <systemProperties>
            <systemproperty>
                <name>jetty.port</name>
                <value>80</value>
            </systemproperty>
        </systemProperties>
    </configuration>
</plugin>
Using this method you can run multiple instances of jetty as well.

Why this no longer works: The org.mortbay.jetty groupId was retired years ago. The <systemProperties> method for setting the port was removed, and the property was renamed to jetty.http.port when Jetty 9 introduced the module system. If you use the old snippet in a modern project, Jetty starts on port 8080 and ignores the setting without showing an error.

2026 Version

Mort Bay was the origin of jetty and new moved to Eclipse, and the Maven groupId changed during this move.

Command line :

For starting jetty server we are using mvn jetty:run command. We can change the port jetty server running by passing runtime argument to it.

mvn -Djetty.http.port=80 jetty:run

The only change from the original post is jetty.port becomes jetty.http.port.

Using Jetty plugin in pom.xml : 

<plugin>
    <groupId>org.eclipse.jetty.ee10</groupId>
    <artifactId>jetty-ee10-maven-plugin</artifactId>
    <version>12.1.10</version>
    <configuration>
        <httpConnector>
            <port>9999</port>
            <!--host>127.0.0.1</host-->
        </httpConnector>
    </configuration>
</plugin>

Maven Project Properties in pom.xml : 

<properties>
    <jetty.http.port>9090</jetty.http.port>
</properties>

3 comments:

  1. Thanks for taking the time to discuss this I feel strongly about it and love learning more on this topic. If possible as you gain expertise would you mind updating your blog with more information? as it is extremely helpful for me. vonage

    ReplyDelete
  2. Thanks... was really helpful.

    ReplyDelete
  3. Thanks... was really helpful.

    ReplyDelete


View Counts

Followers