How to change port for jenkins window service when 8080 is being used
JenkinsJenkins Problem Overview
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.
Jenkins Solutions
Solution 1 - Jenkins
- Go to the directory where you installed Jenkins (by default, it's under Program Files/Jenkins)
- Open the
Jenkins.xml
configuration file - Search
--httpPort=8080
and replace the8080
with the new port number that you wish - Restart Jenkins for changes to take effect
Solution 2 - Jenkins
Restart Jenkins service
Just restart the Jenkins service after you changed the port in jenkins.xml.
- Press Win + R
- Type "services.msc"
- Right click on the "Jenkins" line > Restart
- Type
http://localhost:8081/
in your browser to test the change.
Solution 3 - Jenkins
On Ubuntu 16.04 LTS you can change the Port like that:
- Change port number in the config file
/etc/default/jenkins
to 8081 (or the port you like)HTTP_PORT=8081
- Restart Jenkins:
service jenkins restart
Solution 4 - Jenkins
Start Jenkins from cmd line with this command :
java -jar jenkins.war --httpPort=8081
Solution 5 - Jenkins
If you are running on Redhat, do following
-
Stop Jenkins
$sudo service jenkins stop
-
change port number in
/etc/sysconfig/jenkins
like i did for port 8081
JENKINS_PORT="8081"
-
start Jenkins again
$sudo service jenkins start
make sure your FW has correct burn rules.
Solution 6 - Jenkins
In linux,
sudo vi /etc/sysconfig/jenkins
set following configuration with any available port
JENKINS_PORT="8082"
Solution 7 - Jenkins
Check in Jenkins.xml and update like below
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8090</arguments>
Solution 8 - Jenkins
You should follow 2 steps:
-
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:\folder\Jenkins
-
This step will be helpful to change the port number, and works can be performed accordingly.
java -jar jenkins.war --httpPort=8585
Solution 9 - Jenkins
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.
Solution 10 - Jenkins
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
Solution 11 - Jenkins
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
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
Solution 12 - Jenkins
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 13 - Jenkins
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>
Solution 14 - Jenkins
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