I am setting up a new CI/CD environment, but I already have another web service running on port 8080. Every time I try to launch Jenkins, I run into a port conflict error. I know Jenkins defaults to 8080, but I need to move it to something like 8081 or 9090. Depending on whether I’m running Jenkins as a standalone .war file, a Windows service, or a Linux systemd service, where are the configuration files located, and which specific environment variable or flag needs to be updated to ensure the change persists after a restart?
3 answers
The method for changing the port depends entirely on your installation type.
-
Standalone WAR file: Simply launch it using the
--httpPortflag:java -jar jenkins.war --httpPort=9090 -
Linux (Systemd): Modern Jenkins installations use systemd overrides. Run
Ini, TOMLsudo systemctl edit jenkinsand add:[Service] Environment="JENKINS_PORT=9090" -
Windows Service: Navigate to the Jenkins installation folder and edit the
jenkins.xmlfile. Find the line--httpPort=8080and change it to your desired port, then restart the Jenkins service throughservices.msc.
After making these changes, remember to update your firewall rules (like ufw or iptables) to allow traffic on the new port.
If I’m running Jenkins inside a Docker container, do I still need to go into the container’s configuration files to change the port, or can I just handle the port mapping during the docker run command?
Don't forget to update the Jenkins URL in the system settings! If you change the port but leave the "Jenkins URL" under Manage Jenkins > System pointing to 8080, your email notifications and build links will all be broken.
I agree with Alex. That’s a classic mistake. I spent an hour debugging why my GitHub webhooks weren't working after a port change, and it was simply because I forgot to update the Global Configuration URL to match the new port.
Sarah, for Docker, you don't need to change the internal Jenkins config at all! You can simply map a different host port to the container's 8080. Use the -p flag: docker run -p 9090:8080 jenkins/jenkins. Your browser will access Jenkins at localhost:9090, while Jenkins internally still thinks it's on 8080. This is by far the cleanest way to avoid conflicts in a containerized environment.