How to start jenkins on different port rather than 8080 using command prompt in Windows?

WindowsCommand LineJenkinsWarCommand Prompt

Windows Problem Overview


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?

Windows Solutions


Solution 1 - Windows

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

Solution 2 - Windows

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.

Solution 3 - Windows

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

Solution 4 - Windows

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.

Solution 5 - Windows

On Windows (with Windows Service).

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

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

Solution 6 - Windows

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.

Solution 7 - Windows

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)\Jenkins\jenkins.xml

<executable>%BASE%\jre\bin\java</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%\jre\bin\java</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.

Solution 8 - Windows

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.

Solution 9 - Windows

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

Solution 10 - Windows

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.

Solution 11 - Windows

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"

Solution 12 - Windows

You can call

java -jar jenkins.war --help

to see a list of all available parameters.

Solution 13 - Windows

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

HTTP_PORT=8010
JENKINS_ARGS="--httpPort=$HTTP_PORT"

Solution 14 - Windows

On OSX edit file:

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

and edit port to you needs.

Solution 15 - Windows

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

Solution 16 - Windows

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"

Solution 17 - Windows

Change the '/etc/init.d/jenkins' shell

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

Change 8080 to whichever you want

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2027659View Question on Stackoverflow
Solution 1 - WindowsRipon Al WasimView Answer on Stackoverflow
Solution 2 - WindowsPrasadView Answer on Stackoverflow
Solution 3 - WindowschristianView Answer on Stackoverflow
Solution 4 - WindowskanibalvView Answer on Stackoverflow
Solution 5 - WindowsStéphane GRILLONView Answer on Stackoverflow
Solution 6 - WindowsdjbView Answer on Stackoverflow
Solution 7 - WindowsJin ThakurView Answer on Stackoverflow
Solution 8 - WindowsYounesView Answer on Stackoverflow
Solution 9 - WindowsmainframerView Answer on Stackoverflow
Solution 10 - WindowsVinodh AjView Answer on Stackoverflow
Solution 11 - WindowsAnkush SinghView Answer on Stackoverflow
Solution 12 - Windowsuser2081279View Answer on Stackoverflow
Solution 13 - WindowsVimal MathewView Answer on Stackoverflow
Solution 14 - WindowsPauls BebrisView Answer on Stackoverflow
Solution 15 - WindowsSatyam SinhaView Answer on Stackoverflow
Solution 16 - WindowsAlmazView Answer on Stackoverflow
Solution 17 - WindowsKamelView Answer on Stackoverflow