Changing the default port of Jenkins may be necessary for several reasons:
Port Conflict:
- The default port for Jenkins is 8080. If another application or service is already using this port on your server, there will be a conflict. Changing the port allows you to resolve conflicts and ensure that both Jenkins and the other application can coexist on the same server.
Security Considerations:
- Changing the default port can be a security best practice. Automated bots and malicious users often target well-known ports for attacks. Changing the port number makes it less predictable and adds a layer of security through obscurity.
Firewall or Proxy Configuration:
- In some environments, firewall or proxy configurations may dictate that Jenkins should run on a specific port. Changing the port allows you to align Jenkins with these configuration requirements.
Company Policies:
- Some organisations have specific policies or guidelines that dictate using non-default ports for applications. Adhering to these policies may require changing the Jenkins port.
When changing the port, it's important to consider any implications for firewall rules, network configurations, and how users or other systems interact with Jenkins. Additionally, ensure that the chosen port is not blocked by firewalls and is accessible to users and other systems as needed.
Changing Jenkins Port (METHOD 1)
sudo nano /etc/default/jenkins
Scroll down until you find the following lines:
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080
Edit the second line to include the port number you want to specify. For instance:
HTTP_PORT=8383
Restart Jenkins:
sudo systemctl restart jenkins
Changing Jenkins Port (METHOD 2)
Populate /lib/systemd/system/jenkins.service with configuration parameters for the launch To change jenkins port, set Jenkins to listen on port <PORT_NUMBER>:
Open systemd service file:sudo vi /lib/systemd/system/jenkins.service
change port:
[Service]
Environment="JENKINS_PORT=9191"
Reload units:sudo systemctl daemon-reload
Restart jenkins:sudo systemctl restart jenkins
feel free to ask queries related to this topic. I will be happy to help you.
connect with me:- utkarshsri0701@gmail.com / serv-ar-tistry Studio