DEV Community

Raza
Raza

Posted on

Changing Jenkins Port on Linux: A Step-by-Step Guide

Introduction:

Jenkins, a widely-used automation server in software development, sometimes requires tweaking, such as changing its default port. In this guide, we'll walk through the process of changing the Jenkins port on a Linux system. No tech jargon, just straightforward steps to help you make this adjustment seamlessly.

Steps

Step 1: Stop the Jenkins and find the Jenkins Configuration File.
Locate the Jenkins file:

 sudo systemctl stop jenkins
 cd /etc/default/
 //Take a backup of the jenkins file.
 cp jenkins jenkins_backup
 sudo vim jenkins
Enter fullscreen mode Exit fullscreen mode

Edit the file, find HTTP_PORT and modify it with your preferred port number. For instance:

 HTTP_PORT=8084
Enter fullscreen mode Exit fullscreen mode

After altering the port and saving, start Jenkins:

 sudo systemctl start jenkins
Enter fullscreen mode Exit fullscreen mode

Verify it by visiting http://your_jenkins_instance_ip:8084

Make sure jenkins is still not working on 8080 port or your previous port; incase it does , follow this

sudo vim /usr/lib/systemd/system/jenkins.service
Enter fullscreen mode Exit fullscreen mode

Locate Environment="JENKINS_PORT=8080". Change the port number to new port number and save.

systemctl daemon-reload
systemctl restart jenkins.service
Enter fullscreen mode Exit fullscreen mode

Keep in mind that adjusting the port could impact other services or tools relying on the standard Jenkins port (8080). Confirm that the new port is available and not in use by any other application on your system. Also, don't forget to modify firewall or security group settings if needed! 🚀

Top comments (0)