How to Change the Default Port in Jenkins?
Last Updated :
02 Dec, 2024
Configuring the port in Jenkins is a fundamental aspect of managing the Jenkins server. By default, Jenkins runs on port 8080, but there are scenarios where you may need to change this port to avoid conflicts with other services or security reasons. Understanding how to configure the port in Jenkins ensures smooth operation and accessibility of the Jenkins server. This article will guide you through changing the port in Jenkins, providing step-by-step instructions.
Understanding Default Jenkins Port
Jenkins typically runs on port 8080 by default. This port serves as the entry point for accessing the Jenkins web interface. It's like the front door to your Jenkins server, where you can manage jobs, view build status, and configure settings. Port 8080 is chosen because it's commonly available and not usually occupied by other services. When you type "http://localhost:8080" in your web browser, Jenkins listens on this port and responds, allowing you to interact with the Jenkins server through its user interface.
Changing Default Port in Jenkins in Linux OS
Step 1: Ensure Jenkins is Installed and Running
Firstly ensure that you have already set up the Jenkins software and the Jenkins server is running. For the installation of Jenkins refer to this - Install Jenkins
Step 2: Verify Operating System
Verify the OS of the current VM. To change the default port on which Jenkins runs, you typically need to modify the Jenkins configuration file. The steps may vary depending on your installation method and operating system. Here, we are using Ubuntu OS.
Step 3: Access Jenkins Using the Default Port
Step 4: Verify Jenkins Port
- Locate the Jenkins service file and check the which port currently using the jenkins. Verify the below image and the current port number is 8080.
- For best practice initially we need to stop the service and after change the service again start using the below commands.
sudo systemctl stop jenkins.service
sudo systemctl start jenkins.service
cat /lib/systemd/system/jenkins.service
Step 5: Modify the Jenkins Service File
We have changed the port number to 9090. Using the below command we can change the port number of the jenkins on service file.
vi /lib/systemd/system/jenkins.service
Step 6: Verify New Port
Accessing the changed port through the browser.
For other os like Ubuntu, RedHat etc. you can modify by uisng the below procedure.
sudo vi /etc/default/jenkins
Identify the below one and change the port
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080
Change like below
HTTP_PORT=9090
After changing restart the jenkins server using the below command.
sudo systemctl restart jenkins.service.
Changing Default Port of Jenkins in Windows OS
Let's see how to installing Jenkins on Windows using the Command Prompt (CMD) with your existing OpenJDK 17.
Step 1: Ensure Java is Installed and Available in PATH
Verify Java Installation: Open a Command Prompt and run
java -version
You should see the version you already provided, confirming Java is installed correctly.
Ensure JAVA_HOME is Set: If you haven’t already, set the `JAVA_HOME` environment variable.
- Open CMD as Administrator.
- Set the `JAVA_HOME` to point to your JDK directory:
setx JAVA_HOME "C:\Program Files\OpenJDK\jdk-17.0.12"
You can adjust the path to match the exact location of your JDK installation. This is optional if it is already set.
Step 2: Download and Configure Jenkins
Download Jenkins
- Open a web browser and go to the official Jenkins download page: [Jenkins Downloads](https://www.jenkins.io/download/).
- Under Generic Java Package (.war), click the link to download the `.war` file.
Move the File
- Once downloaded, move the `jenkins.war` file to a folder where you want to keep Jenkins files (e.g., `C:\Jenkins`).
Step 3: Start Jenkins Using CMD
- Open Command Prompt as Administrator.
- Use `cd` to change to the directory where you placed the `jenkins.war` file.
Example:
cd C:\Jenkins
Start Jenkins
java -jar jenkins.war
Jenkins will now start, and you will see logs in the CMD window. By default, Jenkins uses port '8080' unless specified otherwise.
Step 4: Access Jenkins in Your Browser
After Jenkins has started, open your browser and go to:
http://localhost:8080
Unlock Jenkins
- Jenkins will prompt you to unlock it. To do this, you need the initial administrator password.
Retrieve the Initial Admin Password
- Go back to the CMD window and find the part in the Jenkins logs that says:
Please use the following password to proceed to installation:
xxxxxxxxxxxxxxxxxxxxxx
- Copy that password.
- Paste the password into the Jenkins setup page in your browser to unlock Jenkins.
- Now you can start using Jenkins.
Step 5: Change Jenkins Port
To modify the port number when using Jenkins WAR file version, type the following command at the command prompt:
java -jar jenkins.war --httpPort=[port-number]
java -jar jenkins.war --httpPort=9090
- Check the services and locate the jenkins and click on right click and restart the service. Now you can check by refreshing the jenkins page localhost:8080 is able to open jenkins.
- Now you can access the jenkins by using new port 9090.
Now Jenkins should be installed and running on your Windows machine, accessible with change port at 'http://localhost:9090'!
Similar Reads
How to Change the Default Port in PostgreSQL
PostgreSQL is one of the most powerful and widely used relational database management systems (RDBMS) in the world. By default, PostgreSQL listens for incoming connections on port 5432. In this article, we will describe the process of changing the default port for PostgreSQL in detailed and step-by-
6 min read
How to Change the Default Port in Spring Boot?
Spring Boot framework provides a default embedded server i.e. the Tomcat server for many configuration properties to run the Spring Boot application. The application runs on the default port which is 8080. As per the application need, we can also change this default port for the embedded server. In
4 min read
How To Change The Default Port 5000 in Svelte?
In Svelte, the application is by default rendered on port 5000 when using the development server. However, you might want to change this port to avoid conflicts with other applications or to fit specific requirements. It can be done through different approaches, such as updating the package.json fil
3 min read
How to Change FTP Port in Linux?
Files are either uploaded or downloaded to the FTP server. The files are moved from a personal computer to the server when you upload files. The files are moved from the cloud to your personal computer when the files are downloaded. In order to transfer files through FTP, TCP/IP (Transmission Contro
1 min read
How to Change Default MySQL/MariaDB Port in Linux?
The default port that the MySQL database server runs under Linux is 3306/TCP. Use the commands below to change the default MySQL/MariaDB Database port in Linux. vi /etc/mysql/mariadb.conf.d/50-server.cnf Search for the line MYSQL, find port under this line, and replace port values accordingly. [mysq
1 min read
What Is The Default Jenkins Password?
Jenkins is a widely used open-source automation server that is essential to pipelines for continuous integration and delivery (CI/CD). Users frequently find that they must initially log in while installing Jenkins for the first time. This post explores the default Jenkins password and walks readers
4 min read
How to Build React App in Jenkins?
Jenkins is a popular tool for Continuous Integration. Using Jenkins, we can externalize the build process for our code. It allows teams to collaborate more efficiently and deliver software in shorter cycles. In this article, we will learn how to build a react app in Jenkins. Steps To Install Jenkins
7 min read
How to Setup Jenkins in Docker Container?
Setting up of Jenkins in a docker container provides the facility of streamlining the CI/CD with scalability and consistency. It also helps for attaching the worker nodes as slaves and run the build jobs over their. In this article, we will guide you through the process of deploying jenkins in a Doc
6 min read
How to Change Port in Flask app
In this article, we will learn to change the port of a Flask application. The default port for the Flask application is 5000. So we can access our application at the below URL. http://127.0.0.1:5000/ We may want to change the port may be because the default port is already occupied. To do that we ju
1 min read
How to change port in Next.js App
Next.js provides the flexibility to change the default port of the development server using command-line options such as -p <port_number> or by updating the "scripts" section in the package.json file, offering developers multiple ways to customize the port configuration based on their requirem
3 min read