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

264,311

Solution 1

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

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

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

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

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>
Share:
264,311
Admin
Author by

Admin

Updated on September 26, 2021

Comments

  • Admin
    Admin almost 3 years

    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?

  • null
    null over 10 years
    Hi, I did this but after a reboot it reverted to 8080 again, is there a way to change the setting permanently?
  • Christian
    Christian about 10 years
    @SteveGreen: The above mentioned commands are starting Jenkins from the command line. This is not a permant configuration. It is possible to save this command in a batch file and launch that file during startup, e.g. in an autostart folder.
  • adarshr
    adarshr almost 10 years
    Just restarting the service should suffice.
  • Spartan
    Spartan almost 10 years
    1. There is no /etc directory in Windows. 2. This is only a check if the port is already in use. You can change it in Ubuntu/Debian in /etc/default/jenkins: HTTP_PORT=9090
  • Erik
    Erik almost 10 years
    I do not see this file
  • Marian Klühspies
    Marian Klühspies over 9 years
    sadly this seems to not have any effect.it still says fail, port 8080 in use when I change to another port
  • Travis
    Travis about 9 years
    Might be worth pointing out that 'jenkins.xml' is the one located in the same folder as jenkins.exe. Not the one that you may have copied to folder pointed to by environment variable 'JENKINS_HOME'
  • Oscar Barrett
    Oscar Barrett over 8 years
    This file was called jenkins.model.JenkinsLocationConfiguration.xml for me.
  • Jubl
    Jubl about 8 years
    I would like to add that if you are not able to edit the jenkins.xml file on Windows for some reason, drag the file to your desktop. It will let you edit it there. Once you make the changes, drag the file back into the installation directory and restart the service. Big thanks to Prasad for the answer.
  • blackcompe
    blackcompe almost 6 years
    @Jubl: You're a lifesaver! Despite changing the default instance port upon initial Jenkins configuration, verifying that jenkins.xml had the correct httpPort, and restarting the Windows service, it still didn't work. Dragging the file to my desktop (which then reverted the default port back to 8080), editing it, putting it back into the installation folder, and then restarting the service made it work.
  • Ashish Kamble
    Ashish Kamble over 5 years
    It lefts old 8080 and now new 9090 both are working now
  • Ashish Kamble
    Ashish Kamble over 5 years
    @RiponAlWasim is it standard way if i use net start jenkins command to start/stop jenkins services.
  • vljs
    vljs about 5 years
    Works on Ubuntu 18.04 too
  • Dinu Nicolae
    Dinu Nicolae almost 5 years
    it does not work for me. Jenkins refuses to start on any port except for 8080.
  • Dinu Nicolae
    Dinu Nicolae almost 5 years
    It was my bad, it works. I had no Custom TCP Rule on aws for the other port. Thank you.
  • serge3ling
    serge3ling about 4 years
    sudo systemctl restart jenkins restarts the service, too.
  • Darryl RN
    Darryl RN over 3 years
    I changed the port to 80 (because it is not being used by any program), but after i restart the service, the status is active but I can't open it from browser. Do you know what's wrong?
  • manukyanv07
    manukyanv07 over 2 years
    This is not working in amazon linux instance. I changed the port restarted jenkins but still listening to same port.