Как изменить порт jenkins

I installed Jenkins on a windows virtual server and want to run it as window service. Since the port 8080 is being used by other service, I changed the http port to 8081 in jenkins.xml file. Howe...

I installed Jenkins on a windows virtual server and want to run it as window service.

Since the port 8080 is being used by other service, I changed the http port to 8081 in jenkins.xml file. However, I am not able to launch localhost:8081/jenkins at all. I need detail instruction/steps to configure port 8081 or something to run Jenkins.

ROMANIA_engineer's user avatar

asked May 20, 2014 at 20:37

victorialei's user avatar

1

  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. Search --httpPort=8080 and replace the 8080 with the new port number that you wish
  4. Restart Jenkins for changes to take effect

Zeitounator's user avatar

Zeitounator

33.7k7 gold badges44 silver badges60 bronze badges

answered Jan 29, 2015 at 8:02

Nuh Metin Güler's user avatar

4

Restart Jenkins service

Just restart the Jenkins service after you changed the port in jenkins.xml.

  1. Press Win + R
  2. Type «services.msc»
  3. Right click on the «Jenkins» line > Restart

    Restart Jenkins

  4. Type http://localhost:8081/ in your browser to test the change.

answered Feb 8, 2016 at 16:07

ROMANIA_engineer's user avatar

ROMANIA_engineerROMANIA_engineer

53k28 gold badges199 silver badges194 bronze badges

On Ubuntu 16.04 LTS you can change the Port like that:

  1. Change port number in the config file /etc/default/jenkins to 8081 (or the port you like) HTTP_PORT=8081
  2. Restart Jenkins: service jenkins restart

answered Nov 9, 2016 at 13:21

user661545's user avatar

user661545user661545

4594 silver badges3 bronze badges

1

Start Jenkins from cmd line with this command :

java -jar jenkins.war --httpPort=8081

answered May 20, 2014 at 21:02

Cole9350's user avatar

Cole9350Cole9350

5,3562 gold badges33 silver badges50 bronze badges

1

If you are running on Redhat, do following

  1. Stop Jenkins
    $sudo service jenkins stop

  2. change port number in /etc/sysconfig/jenkins like i did for port 8081
    JENKINS_PORT="8081"

  3. start Jenkins again
    $sudo service jenkins start

make sure your FW has correct burn rules.

Community's user avatar

answered Aug 18, 2016 at 23:59

star's user avatar

starstar

6156 silver badges12 bronze badges

In linux,

sudo vi /etc/sysconfig/jenkins

set following configuration with any available port

JENKINS_PORT="8082"

Liam's user avatar

Liam

26.8k27 gold badges120 silver badges184 bronze badges

answered May 17, 2017 at 9:32

Udara Seneviratne's user avatar

0

You should follow 2 steps:

  1. This step can be followed by running the cmd in the specific folder location where there will be .war file. This step helpful as Jenkins needs some disk space to perform builds and keep archives.

    set JENKINS_HOME=c:folderJenkins
    
  2. This step will be helpful to change the port number, and works can be performed accordingly.

    java -jar jenkins.war --httpPort=8585
    

double-beep's user avatar

double-beep

4,85916 gold badges32 silver badges41 bronze badges

answered Aug 5, 2019 at 7:30

Anirban Hazarika's user avatar

2

Check in Jenkins.xml and update like below

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=8090</arguments>

answered Jan 12, 2015 at 14:36

Karan Thakur's user avatar

1 ) Open the jenkins.xml file
2 ) Search for the «—httpPort=8080» Text and replace the port number 8080 with your custom port number (like 7070 , 9090 )
3 ) Go to your services running your machine & find out the Jenkins service and click on restart.

enter image description here

answered Aug 5, 2019 at 18:14

Lova Chittumuri's user avatar

Lova ChittumuriLova Chittumuri

2,7521 gold badge28 silver badges30 bronze badges

Use Default Port

If the default port 8080 has been bind with other process, Then kill that process.

DOS> netstat -a -o -n

Find the process id (PID) XXXX of the process which occupied 8080.

DOS> taskkill /F /PID XXXX

Now, start Jenkins (on default port)

DOS> Java -jar jenkins.war

Use Custom Port

DOS> Java -jar jenkins.war --httpPort=8008

answered Jul 20, 2017 at 18:39

maris's user avatar

marismaris

6787 silver badges7 bronze badges

1

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=8081

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

More info:

https://www.jenkins.io/doc/book/installing/linux/#debianubuntu

answered Apr 1, 2022 at 13:26

hkimani's user avatar

hkimanihkimani

4455 silver badges14 bronze badges

On Windows (with Windows Service).

Edit the file C:Program Files (x86)Jenkinsjenkins.xml with 8083 if you want 8083 port.

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=8083</arguments>

answered Feb 24, 2015 at 12:32

Stéphane GRILLON's user avatar

Stéphane GRILLONStéphane GRILLON

10.7k8 gold badges81 silver badges142 bronze badges

For jenkins in a docker container you can use port publish option in docker run command to map jenkins port in container to different outside port.

e.g. map docker container internal jenkins GUI port 8080 to port 9090 external

docker run -it -d --name jenkins42 --restart always 
   -p <ip>:9090:8080 <image>

answered Jun 7, 2017 at 16:14

gaoithe's user avatar

gaoithegaoithe

4,1083 gold badges28 silver badges38 bronze badges

For Ubuntu there is a small change in paths etc:

First, you need to open the Jenkins config file:

Path for GUI:

/etc/default/jenkins

Command for terminal:

sudo nano /etc/default/jenkins

Note: instead of nano you can use vi, cat, etc

find HTTP_PORT

replace 8080 to any port like:

HTTP_PORT=8282

answered Feb 22, 2022 at 7:53

Mobin Al Hassan's user avatar

Note that since Jenkins 2.332.1, this won’t work anymore, as described in the accepted answer of this post.
Basically, you have to configure Jenkins using systemctl by typing

systemctl edit jenkins

then, pass in:

[Service]
Environment="JENKINS_PORT=<anyPort>"

answered Jun 17, 2022 at 9:20

Oidipous_REXX's user avatar

edit HTTP_PORT in config file:

sudo nano /etc/default/jenkins
# update
# HTTP_PORT=1234
# set any port you want

If this doesn’t resolve the issue,
set the port in jenkins.service file:

sudo nano /lib/systemd/system/jenkins.service
# update
# Environment="JENKINS_PORT=1234"
# set any port you want
sudo nano /etc/systemd/system/jenkins.service.d/override.conf
# update
# Environment="JENKINS_PORT=1234"
# set any port you want

Then restart the service by:

sudo systemctl daemon-reload
sudo systemctl restart jenkins.service
# check status by:
sudo systemctl status jenkins.service

Note: to check if a port is available to use, run:

sudo lsof -i -P -n | grep 'port_number'
# no result will show if port_number is not being used.

answered Jul 26, 2022 at 11:01

KIRAN KUMAR B's user avatar

По умолчанию,  Jenkins использует порт 8080 и при необходимости, его легко можно изменить на любой другой. В своей статье «Изменить порт для Jenkins в Unix/Linux» я расскажу как это можно сделать на разных ОС.

Для начала остановим службу:

┌(vagrant@vagrant-ansible)─(✓)─(04:59 pm Sat Jan 21)
└─(~)─(2 files, 32Kb)─> sudo service jenkins status 
● jenkins.service - LSB: Jenkins Continuous Integration Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Sat 2017-01-21 16:46:39 GMT; 26min ago
     Docs: man:systemd-sysv-generator(8)
   Memory: 43.4M
   CGroup: /system.slice/jenkins.service
           └─10320 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins...

Jan 21 16:46:38 vagrant-ansible systemd[1]: Starting LSB: Jenkins Continuous Integration Server...
Jan 21 16:46:38 vagrant-ansible runuser[10306]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Jan 21 16:46:39 vagrant-ansible systemd[1]: Started LSB: Jenkins Continuous Integration Server.
Jan 21 16:46:39 vagrant-ansible jenkins[10305]: Starting Jenkins [  OK  ]

┌(vagrant@vagrant-ansible)─(✓)─(05:12 pm Sat Jan 21)
└─(~)─(2 files, 32Kb)─> sudo service jenkins stop
Stopping jenkins (via systemctl):                          [  OK  ]

┌(vagrant@vagrant-ansible)─(✓)─(05:12 pm Sat Jan 21)
└─(~)─(2 files, 32Kb)─> sudo service jenkins status 
● jenkins.service - LSB: Jenkins Continuous Integration Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: inactive (dead) since Sat 2017-01-21 17:12:50 GMT; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 12568 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)

Jan 21 16:46:38 vagrant-ansible systemd[1]: Starting LSB: Jenkins Continuous Integration Server...
Jan 21 16:46:38 vagrant-ansible runuser[10306]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Jan 21 16:46:39 vagrant-ansible systemd[1]: Started LSB: Jenkins Continuous Integration Server.
Jan 21 16:46:39 vagrant-ansible jenkins[10305]: Starting Jenkins [  OK  ]
Jan 21 17:12:49 vagrant-ansible systemd[1]: Stopping LSB: Jenkins Continuous Integration Server...
Jan 21 17:12:50 vagrant-ansible jenkins[12568]: Shutting down Jenkins [  OK  ]
Jan 21 17:12:50 vagrant-ansible systemd[1]: Stopped LSB: Jenkins Continuous Integration Server.

┌(vagrant@vagrant-ansible)─(✗)─(05:12 pm Sat Jan 21)
└─(~)─(2 files, 32Kb)─> 

Как видно с вывода, я убедился что он все-таки запущен и остановил его.

Если используете ОС — CentOS

Если вы хотите изменить порт по умолчанию для Jenkins вам необходимо открыть файл:

# vim /etc/sysconfig/jenkins

Находим

JENKINS_PORT="8080"

Измените данный порт на тот который вы хотите.Чтобы Дженкинс работал в интернете можно использовать Apache/Nginx в качестве обратного прокси.

Если используете ОС — Debian/Ubuntu

В deb операционных системах, нужно открыть:

# vim  /etc/default/jenkins

И прописать :

--httpPort=8888

Или любой другой порт в JENKINS_ARGS

После изменений, запускаем службу с дженкинс:

┌(vagrant@vagrant-ansible)─(✓)─(05:13 pm Sat Jan 21)
└─(~)─(2 files, 32Kb)─> sudo service jenkins start 
Starting jenkins (via systemctl):                          [  OK  ]

┌(vagrant@vagrant-ansible)─(✓)─(05:13 pm Sat Jan 21)
└─(~)─(2 files, 32Kb)─>

Вот и все, тема «Изменить порт для Jenkins в Unix/Linux» завершена.

I have jenkins.war and I started it from command prompt in Windows as:

java -jar jenkins.war

It was started well and easily browsed as http://localhost:8080

I want to start on 9090 port. How can I do that?

asked Mar 7, 2013 at 7:18

Use the following command at command prompt:

java -jar jenkins.war --httpPort=9090

If you want to use https use the following command:

java -jar jenkins.war --httpsPort=9090

Details are here

drac_o's user avatar

drac_o

4075 silver badges11 bronze badges

answered Mar 7, 2013 at 7:20

Ripon Al Wasim's user avatar

Ripon Al WasimRipon Al Wasim

36.4k42 gold badges153 silver badges173 bronze badges

4

Open the jenkins.xml in the jenkins home folder (usually C:Program Files (x86)Jenkins) and change the port number:
httpPort=xxxx

to
httpPort=yyyy

then restart the service. it should change the setting permanently.

Aaron D's user avatar

Aaron D

5,7971 gold badge35 silver badges51 bronze badges

answered May 19, 2014 at 5:45

Prasad's user avatar

PrasadPrasad

9396 silver badges2 bronze badges

6

With Ubuntu 14.4 I had to change the file /etc/default/jenkins

E.g.

   #HTTP_PORT=8080
   HTTP_PORT=8083

and restart the service

service jenkins restart

answered Jan 23, 2015 at 9:56

christian's user avatar

christianchristian

8,88210 gold badges39 silver badges51 bronze badges

4

In CentOS/RedHat (assuming you installed the jenkins package)

vim /etc/sysconfig/jenkins

....
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"

change it to any port you want.

rogerdpack's user avatar

rogerdpack

60.5k35 gold badges260 silver badges379 bronze badges

answered Oct 23, 2014 at 21:11

kanibalv's user avatar

kanibalvkanibalv

5914 silver badges4 bronze badges

1

On Windows (with Windows Service).

Edit the file C:Program Files (x86)Jenkinsjenkins.xml with 8083 if you want 8083 port.

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=8083</arguments>

Aaron D's user avatar

Aaron D

5,7971 gold badge35 silver badges51 bronze badges

answered Feb 24, 2015 at 12:35

Stéphane GRILLON's user avatar

Stéphane GRILLONStéphane GRILLON

10.7k8 gold badges81 silver badges142 bronze badges

For the benefit of Linux users who find themselves here: I found /etc/sysconfig/jenkins has a JENKINS_PORT=»8080″, which you should probably change too.

answered Aug 26, 2014 at 9:32

djb's user avatar

djbdjb

1,6033 gold badges25 silver badges49 bronze badges

In *nix
In CentOS/RedHat

vim /etc/sysconfig/jenkins

# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"

In windows open XML file
C:Program Files (x86)Jenkinsjenkins.xml

<executable>%BASE%jrebinjava</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --**httpPort=8083**</arguments>
 i made  above bold  to show you change then 
 <executable>%BASE%jrebinjava</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=8083</arguments>

now you have to restart it doesnot work unless you restart
http://localhost:8080/restart
then after restart
http://localhost:8083/
all should be well so looks like the all above response which says it does not work We have restart.

answered Mar 29, 2016 at 20:10

Jin Thakur's user avatar

Jin ThakurJin Thakur

2,68317 silver badges15 bronze badges

For Fedora, RedHat, CentOS and alike, any customization should be done within /etc/sysconfig/jenkins instead of /etc/init.d/jenkins. The purpose of the first file is exactly the customization of the second file.

So, within /etc/sysconfig/jenkins, there is a the JENKINS_PORT variable that holds the port number on which Jenkins is running.

answered Feb 12, 2015 at 15:44

Younes's user avatar

YounesYounes

1,5971 gold badge18 silver badges32 bronze badges

Correct, use —httpPort parameter. If you also want to specify the $JENKINS_HOME, you can do like this:

java -DJENKINS_HOME=/Users/Heros/jenkins -jar jenkins.war  --httpPort=8484

answered May 19, 2015 at 15:20

mainframer's user avatar

mainframermainframer

19.5k11 gold badges48 silver badges67 bronze badges

To change the default port of 8080. All you need to do:

  1. Goto Jenkins folder present in C:Program Files (x86)
  2. Open a notepad or text pad and run them as administrator and then try opening the jenkins.xml file present in the jenkins folder.
  3. Change the port number as below:
    <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=9090</arguments>
  4. Click Save.

Bhargav Rao's user avatar

Bhargav Rao

48.7k28 gold badges124 silver badges139 bronze badges

answered Feb 23, 2016 at 16:30

Vinodh Aj's user avatar

Vinodh AjVinodh Aj

972 silver badges3 bronze badges

On Debian 11 it ignores /etc/default/jenkins file.
Instead you open /usr/lib/systemd/system/jenkins.service file and replace http-port there in the string:

Environment="JENKINS_PORT=8080"

answered Mar 31, 2022 at 14:27

Almaz's user avatar

AlmazAlmaz

87011 silver badges13 bronze badges

1

Add the following two lines after DAEMON_ARGS in the file /etc/init.d/jenkins

HTTP_PORT=8010
JENKINS_ARGS=»—httpPort=$HTTP_PORT»

answered Jan 28, 2015 at 14:16

Vimal Mathew's user avatar

If you have configured jenkins on ec2 instance with linux AMI and looking to change the port.
Edit the file at

sudo vi /etc/sysconfig/jenkins

Edit

JENKINS_PORT="your port number"

Exit vim

:wq

Restart jenkins

sudo service jenkins restart

Or simply start it, if its not already running

sudo service jenkins start

To verify if your jenkins is running on mentioned port

netstat -lntu | grep "your port number"

answered Feb 21, 2019 at 10:08

Ankush Singh's user avatar

2

You can call

java -jar jenkins.war --help

to see a list of all available parameters.

answered Oct 15, 2014 at 12:51

user2081279's user avatar

user2081279user2081279

7438 silver badges12 bronze badges

On OSX edit file:

/usr/local/Cellar/jenkins-lts/2.46.1/homebrew.mxcl.jenkins-lts.plist

and edit port to you needs.

Sagar V's user avatar

Sagar V

12k7 gold badges44 silver badges67 bronze badges

answered Apr 7, 2017 at 6:01

Pauls Bebris's user avatar

Open Command Prompt as Administrator in Windows .
Go to the directory where Jenkins is installed.
and stop the Jenkins service first, using jenkins.exe stop

type the command to change the port using, java -jar jenkins.war —httpPort=9090 (enter the port number you want to use).

and at-last, restart the Jenkins services, using jenkins.exe restart

answered Feb 18, 2020 at 10:54

Satyam Sinha's user avatar

Change the ‘/etc/init.d/jenkins’ shell

check_tcp_port "http" "$HTTP_PORT" "8080" || return 1

Change 8080 to whichever you want

answered Jul 23, 2014 at 6:42

Kamel's user avatar

KamelKamel

1,8661 gold badge15 silver badges25 bronze badges

1

I have jenkins.war and I started it from command prompt in Windows as:

java -jar jenkins.war

It was started well and easily browsed as http://localhost:8080

I want to start on 9090 port. How can I do that?

asked Mar 7, 2013 at 7:18

Use the following command at command prompt:

java -jar jenkins.war --httpPort=9090

If you want to use https use the following command:

java -jar jenkins.war --httpsPort=9090

Details are here

drac_o's user avatar

drac_o

4075 silver badges11 bronze badges

answered Mar 7, 2013 at 7:20

Ripon Al Wasim's user avatar

Ripon Al WasimRipon Al Wasim

36.4k42 gold badges153 silver badges173 bronze badges

4

Open the jenkins.xml in the jenkins home folder (usually C:Program Files (x86)Jenkins) and change the port number:
httpPort=xxxx

to
httpPort=yyyy

then restart the service. it should change the setting permanently.

Aaron D's user avatar

Aaron D

5,7971 gold badge35 silver badges51 bronze badges

answered May 19, 2014 at 5:45

Prasad's user avatar

PrasadPrasad

9396 silver badges2 bronze badges

6

With Ubuntu 14.4 I had to change the file /etc/default/jenkins

E.g.

   #HTTP_PORT=8080
   HTTP_PORT=8083

and restart the service

service jenkins restart

answered Jan 23, 2015 at 9:56

christian's user avatar

christianchristian

8,88210 gold badges39 silver badges51 bronze badges

4

In CentOS/RedHat (assuming you installed the jenkins package)

vim /etc/sysconfig/jenkins

....
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"

change it to any port you want.

rogerdpack's user avatar

rogerdpack

60.5k35 gold badges260 silver badges379 bronze badges

answered Oct 23, 2014 at 21:11

kanibalv's user avatar

kanibalvkanibalv

5914 silver badges4 bronze badges

1

On Windows (with Windows Service).

Edit the file C:Program Files (x86)Jenkinsjenkins.xml with 8083 if you want 8083 port.

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=8083</arguments>

Aaron D's user avatar

Aaron D

5,7971 gold badge35 silver badges51 bronze badges

answered Feb 24, 2015 at 12:35

Stéphane GRILLON's user avatar

Stéphane GRILLONStéphane GRILLON

10.7k8 gold badges81 silver badges142 bronze badges

For the benefit of Linux users who find themselves here: I found /etc/sysconfig/jenkins has a JENKINS_PORT=»8080″, which you should probably change too.

answered Aug 26, 2014 at 9:32

djb's user avatar

djbdjb

1,6033 gold badges25 silver badges49 bronze badges

In *nix
In CentOS/RedHat

vim /etc/sysconfig/jenkins

# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"

In windows open XML file
C:Program Files (x86)Jenkinsjenkins.xml

<executable>%BASE%jrebinjava</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --**httpPort=8083**</arguments>
 i made  above bold  to show you change then 
 <executable>%BASE%jrebinjava</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=8083</arguments>

now you have to restart it doesnot work unless you restart
http://localhost:8080/restart
then after restart
http://localhost:8083/
all should be well so looks like the all above response which says it does not work We have restart.

answered Mar 29, 2016 at 20:10

Jin Thakur's user avatar

Jin ThakurJin Thakur

2,68317 silver badges15 bronze badges

For Fedora, RedHat, CentOS and alike, any customization should be done within /etc/sysconfig/jenkins instead of /etc/init.d/jenkins. The purpose of the first file is exactly the customization of the second file.

So, within /etc/sysconfig/jenkins, there is a the JENKINS_PORT variable that holds the port number on which Jenkins is running.

answered Feb 12, 2015 at 15:44

Younes's user avatar

YounesYounes

1,5971 gold badge18 silver badges32 bronze badges

Correct, use —httpPort parameter. If you also want to specify the $JENKINS_HOME, you can do like this:

java -DJENKINS_HOME=/Users/Heros/jenkins -jar jenkins.war  --httpPort=8484

answered May 19, 2015 at 15:20

mainframer's user avatar

mainframermainframer

19.5k11 gold badges48 silver badges67 bronze badges

To change the default port of 8080. All you need to do:

  1. Goto Jenkins folder present in C:Program Files (x86)
  2. Open a notepad or text pad and run them as administrator and then try opening the jenkins.xml file present in the jenkins folder.
  3. Change the port number as below:
    <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%jenkins.war" --httpPort=9090</arguments>
  4. Click Save.

Bhargav Rao's user avatar

Bhargav Rao

48.7k28 gold badges124 silver badges139 bronze badges

answered Feb 23, 2016 at 16:30

Vinodh Aj's user avatar

Vinodh AjVinodh Aj

972 silver badges3 bronze badges

On Debian 11 it ignores /etc/default/jenkins file.
Instead you open /usr/lib/systemd/system/jenkins.service file and replace http-port there in the string:

Environment="JENKINS_PORT=8080"

answered Mar 31, 2022 at 14:27

Almaz's user avatar

AlmazAlmaz

87011 silver badges13 bronze badges

1

Add the following two lines after DAEMON_ARGS in the file /etc/init.d/jenkins

HTTP_PORT=8010
JENKINS_ARGS=»—httpPort=$HTTP_PORT»

answered Jan 28, 2015 at 14:16

Vimal Mathew's user avatar

If you have configured jenkins on ec2 instance with linux AMI and looking to change the port.
Edit the file at

sudo vi /etc/sysconfig/jenkins

Edit

JENKINS_PORT="your port number"

Exit vim

:wq

Restart jenkins

sudo service jenkins restart

Or simply start it, if its not already running

sudo service jenkins start

To verify if your jenkins is running on mentioned port

netstat -lntu | grep "your port number"

answered Feb 21, 2019 at 10:08

Ankush Singh's user avatar

2

You can call

java -jar jenkins.war --help

to see a list of all available parameters.

answered Oct 15, 2014 at 12:51

user2081279's user avatar

user2081279user2081279

7438 silver badges12 bronze badges

On OSX edit file:

/usr/local/Cellar/jenkins-lts/2.46.1/homebrew.mxcl.jenkins-lts.plist

and edit port to you needs.

Sagar V's user avatar

Sagar V

12k7 gold badges44 silver badges67 bronze badges

answered Apr 7, 2017 at 6:01

Pauls Bebris's user avatar

Open Command Prompt as Administrator in Windows .
Go to the directory where Jenkins is installed.
and stop the Jenkins service first, using jenkins.exe stop

type the command to change the port using, java -jar jenkins.war —httpPort=9090 (enter the port number you want to use).

and at-last, restart the Jenkins services, using jenkins.exe restart

answered Feb 18, 2020 at 10:54

Satyam Sinha's user avatar

Change the ‘/etc/init.d/jenkins’ shell

check_tcp_port "http" "$HTTP_PORT" "8080" || return 1

Change 8080 to whichever you want

answered Jul 23, 2014 at 6:42

Kamel's user avatar

KamelKamel

1,8661 gold badge15 silver badges25 bronze badges

1

Introduction

Jenkins uses port 8080 by default. However, it also allows users to change the default port to suit their preferences.

In this tutorial, we will go over different methods of changing the default port for Jenkins.

How to change port for Jenkins

Prerequisites

  • A copy of Jenkins installed and ready to use (learn how to install Jenkins on Ubuntu 18.04, Debian 10, CentOS 8, or Windows 10).
  • Access to a web browser.
  • Access to a text editor, such as Nano (Linux and macOS) or Notepad++ (Windows).
  • Access to the terminal (Linux and macOS) or command prompt (Windows).
  • Access to a user account with sudo/administrator privileges.

If you have the Jenkins application installed on a Windows system, changing the Jenkins port number requires editing the jenkins.xml configuration file. You can find this file in the Jenkins install folder (the default path is C:Program FilesJenkinsjenkins.xml).

Open the file using a text editor such as Notepad or Notepad++. Scroll down until you find the line that contains --httpPort=8080 and change the number to the port you want to set.

For instance, changing to port 8081:

--httpPort=8081
Changing the Jenkins port number using the configuration file in Windows

If you are using the WAR file version of Jenkins, use the following command in the command prompt to change the port number:

java -jar jenkins.war --httpPort=[port number]

Continuing with our example, to change the port number to 8081, use:

java -jar jenkins.war --httpPort=8081

Note: If you are using HTTPS with Jenkins, use java -jar jenkins.war --httpsPort=[port number] to change the port in the command prompt.

Both methods require you to restart the Jenkins service for the changes to take effect. Press Win+R to open the Run window, then type «services.msc» and click OK to start the Windows Services window.

Scroll down until you find the Jenkins service. Right-click and select Restart to restart the service.

Restarting the Jenkins service in Windows

Note: Changing the port number affects the Jenkins URL when accessing the Jenkins dashboard from your web browser. The new Jenkins URL combines your system’s hostname and the new port number. Using the example above, the new Jenkins URL would be http://localhost:8081/.

Change Port for Jenkins in Linux

1. Start by opening the Jenkins configuration file with:

sudo nano /etc/default/jenkins

2. Scroll down until you find the following lines:

# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080

3. Edit the second line to include the port number you want to specify. For instance:

HTTP_PORT=8081
Changing the Jenkins port number using the configuration file in Linux

4. Press Ctrl+X, then type Y and press Enter to save the changes you made.

5. Restart the Jenkins service to confirm the changes:

sudo systemctl restart jenkins

Change Port for Jenkins in MacOS

1. To change the default Jenkins port number in MacOS, edit the Jenkins configuration file with:

sudo defaults write /Library/Preferences/org.jenkins-ci httpPort [port number]

2. For example, changing to port 8081:

sudo defaults write /Library/Preferences/org.jenkins-ci httpPort 8081

3. Restart the Jenkins service for the changes to take effect using the following commands:

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Conclusion

After reading this article, you should be able to change the default port number for Jenkins to the one that best suits your needs.

Next, you might want to look into reusable Jenkins environment variables.

Slide 1

Most trusted JOB oriented professional program

DevOps Certified Professional (DCP)

Take your first step into the world of DevOps with this course, which will help you to learn about the methodologies and tools used to develop, deploy, and operate high-quality software.

Slide 2

DevOps to DevSecOps – Learn the evolution

DevSecOps Certified Professional (DSOCP)

Learn to automate security into a fast-paced DevOps environment using various open-source tools and scripts.

Slide 2

Get certified in the new tech skill to rule the industry

Site Reliability Engineering (SRE) Certified Professional

A method of measuring and achieving reliability through engineering and operations work – developed by Google to manage services.

Slide 2

Master in DevOps Engineering (MDE)

Get enrolled for the most advanced and only course in the WORLD which can make you an expert and proficient Architect in DevOps, DevSecOps and Site Reliability Engineering (SRE) principles together.

Slide 2

Gain expertise and certified yourself

Azure DevOps Solutions Expert

Learn about the DevOps services available on Azure and how you can use them to make your workflow more efficient.

Slide 3

AWS Certified DevOps Professional

Learn about the DevOps services offered by AWS and how you can use them to make your workflow more efficient.

previous arrow

next arrow

How to Change Jenkins HTTP port number?

Change a jenkins web http port in Windows
Step 1 – Stop the jenkins services
Step 2 – Go to the directory where you installed the Jenkins (In default, it is under Program Files/Jenkins)
Step 3 – Open the Jenkins.xml
Step 4 – Search –httpPort=8080 and replace the 8080 with the new port number that you wish.
Step 5 – Start the jenkins services

Change a jenkins Slave/Agent port in Windows

Step 1 – Stop the jenkins services
Step 2 – Go to the directory where you installed the Jenkins (In default, it is under Program Files/Jenkins)
Step 3 – Open the config.xml
Step 4 – Search “<slaveAgentPort>50000</slaveAgentPort>” and replace the 50000 with the new port number that you wish.
Step 5 – Start the jenkins services

Change a Jenkins web http port in Linux
Step 1 – Stop the Jenkins services

Step 2 – Know the information about Jenkins installation using the command “ps -eaf | grep Jenkins”

Step 3 – edit /etc/init.d/jenkins and look for jenkins config file “JENKINS_CONFIG=/etc/sysconfig/jenkins”

Step 4 – edit /etc/sysconfig/Jenkins and modify JENKINS_PORT=”8080″

Step 5 – Start the Jenkins services

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-1

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-2

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-3

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-4

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-5

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-6

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-7

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-8

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-9

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-10

play

Jenkins Complete Referenece by Rajesh Kumar in 2020 – Session-11

  • Author
  • Recent Posts

Rajesh Kumar

Mentor for DevOps — DevSecOps — SRE — Cloud — Container & Micorservices at Cotocus

Join my following certification courses…
— DevOps Certified Professionals (DCP)
— Site Reliability Engineering Certified Professionals (SRECP)
— Master in DevOps Engineering (MDE)
— DevSecOps Certified Professionals (DSOCP)
URL — https://www.devopsschool.com/certification/

My Linkedin — https://www.linkedin.com/in/rajeshkumarin
My Email — contact@DevOpsSchool.com

Rajesh Kumar

The jenkins Build and Integration application based on java programming language, tends to have its roots stuck to the typical Tomcat web server
Out of the box the jenkins starts up on the default port 8080 and this can be customized on the system or a new proxy routing can be setup which might add a slight overhead on the jenkins inbound requests,

How to change the Jenkins default Port?

We have the Jenkins default home located at /var/lib/jenkins all the configuration files are present in this location.
The important configuration although is /etc/sysconfig/jenkins which is present outside $JENKINS_HOME
The Jenkins Default JENKINS_PORT parameter is set to 8080

[root@node02 jenkins]# grep JENKINS_PORT /etc/sysconfig/jenkins
JENKINS_PORT="8080"

If you are on Debian or Ubuntu linux, then the relevant file will be /etc/default/jenkins
We will be now changing the variable $JENKINS_HOME to listen to the port 9090 and restarting the jenkins service.

[root@node02 jenkins]# systemctl restart jenkins.service

You can check for the port information from the ps -ef | grep jenkins output as follows or checkout from the netstat command

[root@node02 jenkins]# ps -ef |grep jenkins
jenkins 5110 1 90 23:04 ? 00:00:02 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=9090 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20

How do I change the default Jenkins port in Linux?

  1. First, run this command to open jenkins configurations: sudo nano /etc/default/jenkins.
  2. The only part you need to change is: #port for HTTP connector (default 8080; disable with -1) Http_port = 8080. …
  3. Finally, Restart Jenkins service by running this command: sudo service jenkins restart.

How do I change my local Jenkins port?

  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. Search –httpPort=8080 and replace the 8080 with the new port number that you wish.
  4. Restart Jenkins for changes to take effect.

How do I change my Jenkins port from 8080 to 80?

  1. Go to /etc/default folder –> Open the file “jenkins”
  2. Modify the line HTTP_PORT=8080 as HTTP_PORT=80.
  3. Start jenkins as root by using the command: sudo /etc/init.d/jenkins start.
  4. Open a browser and browse as localhost:80.

What port is Jenkins running on?

The default Jenkins installation runs on ports 8080 and 8443. Typically, HTTP/HTTPS servers run on ports 80 and 443, respectively. But these ports are considered privileged on Unix/Linux systems, and the process using them must be owned by root.

How to change the default port in Jenkins

  1. Go to C:Program Files (x86)Jenkins (I’m using Windows Server 2012 and assuming it’s installed to default location)
  2. Open Jenkins.xml.
  3. Edit the –httpPort argument (you may need to edit default permissions)
  4. Restart the Jenkins service.
  5. Now Jenkins will permanently use the new port.

How do I run a Jenkins war on another port?

All you need to do:

  1. Goto Jenkins folder present in C:Program Files (x86)
  2. Open a notepad or text pad and run them as administrator and then try opening the jenkins. xml file present in the jenkins folder.
  3. Change the port number as below: <arguments>-Xrs -Xmx256m -Dhudson. lifecycle=hudson. lifecycle.

How do I change my Jenkins URL?

Fixing a root url

  1. Go to Jenkins > Manage Jenkins > Configure System, and locate the section titled “Jenkins Location”. You should see the warning here as well.
  2. Replace “localhost” with a valid hostname.
  3. Click Save.

How do I start Jenkins manually in Linux?

Go to the Jenkins installation, open the cmd and run:

  1. To stop: jenkins.exe stop.
  2. To start: jenkins.exe start.
  3. To restart: jenkins.exe restart.

What is Jenkins port 50000?

Jenkins runs on Tomcat, which uses port 8080 as the default. -p 5000:5000 required to attach slave servers; port 50000 is used to communicate between master and slaves.

How do I run Jenkins on port 443?

Basic solution (complete):

  1. You need a “Java keystore” of the SSL-certificate you want to use. …
  2. Copy the certificate, private key and (if present) intermediate CAs to your Jenkins host. …
  3. Convert the certificate-files to one single-filed PKCS12 container. …
  4. Make sure, that the Java “keystore”-command is present.

Like this post? Please share to your friends:
  • Как изменить порт ftp сервера
  • Как изменить порт ftp ubuntu
  • Как изменить порт flask
  • Как изменить порт dynmap
  • Как изменить порт apache2