How to Change the Default Port in Jenkins? (original) (raw)

Last Updated : 23 Jul, 2025

Configuring the port in Jenkins is a fundamental aspect of managing the Jenkins server. By **default, **Jenkins runs on **port 8080, but there are scenarios where you may need to change this port to avoid conflicts with other services or security reasons. Understanding how to configure the port in Jenkins ensures smooth operation and accessibility of the Jenkins server. This article will guide you through changing the port in Jenkins, providing step-by-step instructions.

Understanding Default Jenkins Port

Jenkins typically runs on port 8080 by default. This port serves as the entry point for accessing the Jenkins web interface. It's like the front door to your Jenkins server, where you can manage jobs, view build status, and configure settings. Port 8080 is chosen because it's commonly available and not usually occupied by other services. When you type ****"http://localhost:8080"** in your web browser, Jenkins listens on this port and responds, allowing you to interact with the Jenkins server through its user interface.

Changing Default Port in Jenkins in Linux OS

**Step 1: Ensure Jenkins is Installed and Running

Firstly ensure that you have already set up the Jenkins software and the Jenkins server is running. For the installation of Jenkins refer to this - Install Jenkins

**Step 2: Verify Operating System

Verify the OS of the current VM. To change the default port on which Jenkins runs, you typically need to modify the Jenkins configuration file. The steps may vary depending on your installation method and operating system. Here, we are using Ubuntu OS.

knowing-the-os-details

**Step 3: Access Jenkins Using the Default Port

Accessing-the-server

**Step 4: Verify Jenkins Port

sudo systemctl stop jenkins.service
sudo systemctl start jenkins.service

cat /lib/systemd/system/jenkins.service

Configuring-Jenkins-Server

**Step 5: Modify the Jenkins Service File

We have changed the port number to 9090. Using the below command we can change the port number of the jenkins on service file.

vi /lib/systemd/system/jenkins.service

Changing-the-Port-Number

**Step 6: Verify New Port

Accessing the changed port through the browser.

Accessing-the-jenkins-with-new-port

**For other os like Ubuntu, RedHat etc. you can modify by uisng the below procedure.

sudo vi /etc/default/jenkins

Identify the below one and change the port

port for HTTP connector (default 8080; disable with -1)

HTTP_PORT=8080

Change like below

HTTP_PORT=9090

After changing restart the jenkins server using the below command.

sudo systemctl restart jenkins.service.

Changing Default Port of Jenkins in Windows OS

Let's see how to installing Jenkins on Windows using the Command Prompt (CMD) with your existing OpenJDK 17.

**Step 1: Ensure Java is Installed and Available in PATH

**Verify Java Installation: Open a Command Prompt and run

java -version

You should see the version you already provided, confirming Java is installed correctly.

check-java-version

**Ensure JAVA_HOME is Set: If you haven’t already, set the **`JAVA_HOME` environment variable.

setx JAVA_HOME "C:\Program Files\OpenJDK\jdk-17.0.12"

You can adjust the path to match the exact location of your JDK installation. This is optional if it is already set.

Step 2: Download and Configure Jenkins

**Download Jenkins

**Move the File

verify-jenkinswar-folder

Step 3: Start Jenkins Using CMD

**Example:

cd C:\Jenkins

**Start Jenkins

java -jar jenkins.war

java--jar-jenkinswar

Jenkins will now start, and you will see logs in the CMD window. By default, Jenkins uses port '8080' unless specified otherwise.

Step 4: Access Jenkins in Your Browser

After Jenkins has started, open your browser and go to:

http://localhost:8080

localhost

**Unlock Jenkins

**Retrieve the Initial Admin Password

Step 5: Change Jenkins Port

To modify the port number when using Jenkins WAR file version, type the following command at the command prompt:

java -jar jenkins.war --httpPort=[port-number]

java -jar jenkins.war --httpPort=9090

accessing-the-jenkins-with-9090

Refresh-the-page

Access the server using port 9090

Now Jenkins should be installed and running on your Windows machine, accessible with change port at 'http://localhost:9090'!