![]() |
VOOZH | about |
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.
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.
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
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.
sudo systemctl stop jenkins.service
sudo systemctl start jenkins.service
cat /lib/systemd/system/jenkins.serviceWe 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.serviceAccessing the changed port through the browser.
For other os like Ubuntu, RedHat etc. you can modify by uisng the below procedure.
sudo vi /etc/default/jenkinsIdentify the below one and change the port
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080
Change like below
HTTP_PORT=9090After changing restart the jenkins server using the below command.
sudo systemctl restart jenkins.service.Let's see how to installing Jenkins on Windows using the Command Prompt (CMD) with your existing OpenJDK 17.
Verify Java Installation: Open a Command Prompt and run
java -versionYou should see the version you already provided, confirming Java is installed correctly.
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.
Download Jenkins
Move the File
Example:
cd C:\JenkinsStart Jenkins
java -jar jenkins.warJenkins will now start, and you will see logs in the CMD window. By default, Jenkins uses port '8080' unless specified otherwise.
After Jenkins has started, open your browser and go to:
http://localhost:8080Unlock Jenkins
Retrieve the Initial Admin Password
Please use the following password to proceed to installation:
xxxxxxxxxxxxxxxxxxxxxx
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=9090Now Jenkins should be installed and running on your Windows machine, accessible with change port at 'http://localhost:9090'!