How to Change the Port in Jenkins?

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, such as to avoid conflicts with other services or for security reasons. Understanding how to configure the port in Jenkins ensures smooth operation and accessibility of the Jenkins server. This guide will walk you through the process of changing the port in Jenkins, providing step-by-step instructions and helpful tips along the way.

Understanding Of 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.

How To Change Jenkins Default Port? A Step-By-Step Guide

Step 1: Firstly ensure that you have already setup the Jenkins software and the Jenkins server is in a running state. For the installation of Jenkins refer this – Install Jenkins

Step 2: 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. For demonstration purposes Now we have to take the Amazon Linux os.

Step 3: Accessing the jenkins using the default port number.

Step 4: Locate the jenkins service file and check the which port currently using the jenkins. verify the below image and the current port number is 8080.

  • For best practice initially we need to stop the service and after change the service again start uaing the below commands.
sudo systemctl stop jenkins.service
sudo ststemctl start jenkins.service
cat /lib/systemd/system/jenkins.service

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

vi /lib/systemd/system/jenkins.service

  • Step 6: Accessing the changed port through the browser.

Step 7: 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.

How To Change Port For Jenkins In Windows : A Step-By-Step Guide

Modifying the Jenkins port number necessitates updating the jenkins.xml configuration file if the Jenkins application is installed on a Windows computer. This file is located in the Jenkins install folder (C:\Program Files\Jenkins\jenkins.xml is the normal path).

Step 1: Locate the jenkins.xml and open with the editor. Check the below image httpPort=9090 by default here the port is 8080 and we have changed the port to 9090.

Step 2: Not accessing the with the 9090 port but not accessible. Because the port is still not activated. Restart the service by following the step3.

Step 3: Check the services and locate the jenkins and click on right click and restart the service.

Step 4: After restarting the service we are accessible the jenkins. Verify the below image.

  • 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

Change The Port In Jenkins – FAQ’s

How To Change The Jenkins Default Port?

Find the file with the Jenkins configuration. After making changes to the file’s port configuration, restart Jenkins.

How Do I Change The Port On Jenkins Agent?

Usually, you have to modify the JNLP port configuration in order to alter the port on a Jenkins agent. To do this, you must go into the agent’s configuration settings and change the “JNLP port” field to the desired port number. Jenkins will communicate with agents using the new port after it has been upgraded.

What Port Is Jenkins Running On?

Jenkins by default uses ports 50000 for agent communication and 8080 for HTTP. Nevertheless, these ports are modifiable according to the configuration options specified during Jenkins setup or installation.

How Do I Access Jenkins On Port 8080?

If Jenkins is operating locally, open a web browser and go to “http://localhost:8080” to access Jenkins on port 8080. If Jenkins is hosted on a remote server, the IP address or domain name of the server should be used in place of “localhost.”

How Do I Access Jenkins CLI?

You can use the command java -jar jenkins-cli.jar with the necessary arguments for your intended action to access Jenkins CLI. Make sure you have downloaded the Jenkins CLI jar file and that you have the rights to run the commands.



Contact Us