1

I am trying to change the Jenkins port from default 8080 to port 80.

so I modified the file /etc/sysconfig/jenkins and changed the variable JENKINS_PORT="8080" to JENKINS_PORT="80".

after changing the port I restarted jenkins service by systemctl restart jenkins and the service status was Active: active (exited).

I changed the port back to 8080 and after restart the service status was Active: active (running)which is good, I also tried to change the port to 8081 and the service status was Active: active (running) as well, just when I am trying to use port 80 the service status is Active: active (exited).

I tried to verify if port 80 is in use using netstat -pnltu | grep -i "80" and the port not in use, I tried to configure port 83 just for testing and I get the same behavior as port 80 configured (Active: active (exited))

Am I missing something here?

Dani Wol.
  • 137
  • 7

2 Answers2

0

You can do it in below way:

1. Go to the directory where you installed Jenkins (by default, it's under Program Files/Jenkins)

2. Open the Jenkins.xml configuration file.

3. You can find --httpPort=8080 and replace the 8080 with the new port number.

Restart your Jenkins server.
$ jenkins.exe restart

You can also refer How to configure Jenkins to run on port 80

Altaf
  • 2,343
  • 1
  • 15
  • 7
  • As you can see in my details I am using a Linux instance and not Windows, I changed this parameter on my Linux instance, the `--httpPort=` parameter have a variable as a value and as I mentioned I changed this variable's value from `JENKINS_PORT="8080"` to `JENKINS_PORT="80"` – Dani Wol. Jun 30 '21 at 18:41
  • @Dani Wol the link that I reffered gives answer about linux instance – Altaf Jun 30 '21 at 18:42
  • Tried this but in this example, they are using Ubuntu and I use Redhat distribution, some of the commands cannot executable. for example the `exec daemon`. – Dani Wol. Jun 30 '21 at 18:58
0

I found a solution, I changed the JENKINS_USER variable value from jenkins to root on /etc/sysconfig/jenkins.

Then I restarted Jenkins service using the command:

systemctl restart jenkins

and the service is running.

Dani Wol.
  • 137
  • 7
  • 1
    You really do not want to be running Jenkins as root! Massive security risk. Just give jenkins sudo permission on `/usr/bin/systemctl` or `/sbin/service`. That lets root stop/start Jenkins, but Jenkins app runs as jenkins user; [much more secure](https://www.jenkins.io/doc/book/security/securing-jenkins/) – Ian W Jul 01 '21 at 00:58
  • Yeah, finally I installed Nginx and forward port 80 to 8080 and keep the jenkins_user parameter to jenkins. – Dani Wol. Jul 02 '21 at 07:22