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