When Jenkins and my other apps both claimed port 8080, my workflows kept crashing. I tried editing /etc/default/jenkins
, fiddling with HTTP_PORT
, and even invoking systemctl edit jenkins
—but Jenkins stubbornly stuck to --httpPort=8080
. It took digging into systemd’s drop‑in mechanism and learning that modern Jenkins packages ignore /etc/default/jenkins
in favor of JENKINS_PORT
overrides to break free from port conflicts. In this post, I’ll walk you through exactly what went wrong, why those common fixes failed, and the four commands that finally moved Jenkins to port 9595—all with citations to official docs and community wisdom.
đź§© The Problem
-
Changing
/etc/default/jenkins
had no effect. I set:
HTTP_PORT=9595
restarted Jenkins, but:
ps aux | grep jenkins
still showed --httpPort=8080
(stackoverflow.com).
-
systemctl edit jenkins
overrides weren’t applying. No matter what I saved,/etc/systemd/system/jenkins.service.d/override.conf
stayed empty or missing, so the service unit never picked up my port (askubuntu.com).
🕵️ What Went Wrong ⚠️
-
Jenkins 2.332.1+ packages now use systemd exclusively. They ignore
/etc/default/jenkins
and migrate old init settings into drop‑in overrides (jenkins.io). - Although many guides still reference
HTTP_PORT
, the systemd unit actually honorsJENKINS_PORT
(devops.stackexchange.com). - Without a valid override file in
/etc/systemd/system/jenkins.service.d/
, Jenkins kept launching with its built‑in--httpPort=8080
argument (community.jenkins.io).
🛠️ Step‑by‑Step Fix: Manual Drop‑In Override
1. Create the override directory
sudo mkdir -p /etc/systemd/system/jenkins.service.d/
This ensures systemd will look for custom overrides (jenkins.io).
2. Create (or edit) override.conf
sudo nano /etc/systemd/system/jenkins.service.d/override.conf
Add these lines:
[Service]
Environment="JENKINS_PORT=9595"
Why
JENKINS_PORT
? The official systemd unit template reads this variable when starting Jenkins, unlikeHTTP_PORT
(medium.com, devops.stackexchange.com).
Save and exit (Ctrl+O
→ Enter
→ Ctrl+X
).
3. Reload systemd & restart Jenkins
sudo systemctl daemon-reload
sudo systemctl restart jenkins
This makes systemd pick up your new override (jenkins.io).
4. Verify the new port
sudo ss -tuln | grep 9595
ps aux | grep jenkins
You should now see --httpPort=9595
instead of 8080
(phoenixnap.com).
🎉 Why This Works
- systemd drop‑in files are the supported way to customize services without editing core unit files, which get overwritten on upgrades (jenkins.io).
- Overriding
JENKINS_PORT
hooks into Jenkins’s existing startup logic—no need to rewrite the entireExecStart
(devops.stackexchange.com). - This approach is upgrade‑safe, avoids manual edits to
/lib/systemd/system/jenkins.service
, and aligns with Jenkins’s official recommendations (jenkins.io).
đź§Ş Common Gotchas
Mistake | Why it fails | Correct fix |
---|---|---|
Editing /etc/default/jenkins
|
Ignored by modern systemd‑managed packages | Use drop‑in override with JENKINS_PORT
|
Modifying core systemd unit file | Overwritten on upgrades | Create /etc/systemd/system/...d/override.conf (jenkins.io) |
systemctl edit didn’t save |
Editor or permissions issue | Manually create the file as above |
Still seeing port 8080 | Override file missing or malformed | Confirm /etc/systemd/system/jenkins.service.d/override.conf exists and is correct |
âś… Final Checklist
- Confirm override file exists:
ls -l /etc/systemd/system/jenkins.service.d/override.conf
- Inspect its contents:
cat /etc/systemd/system/jenkins.service.d/override.conf
- Reload & restart:
sudo systemctl daemon-reload
sudo systemctl restart jenkins
- Verify the port:
sudo ss -tuln | grep 9595
ps aux | grep jenkins
🚀 Beyond the Port
-
SSL/TLS via reverse proxy (Nginx/Apache) — leverage
JENKINS_HTTPS_PORT
in the same drop‑in (devops.stackexchange.com). -
Additional JVM options — set
Environment="JAVA_OPTS=…"
alongsideJENKINS_PORT
for memory tuning or custom flags. - Automate with Ansible or Puppet — manage your override file declaratively so every build agent uses the same port.
Happy building!
References
- Changelog for Jenkins systemd overrides — Jenkins official docs (jenkins.io)
- Ask Ubuntu: Changed Jenkins port doesn’t apply (askubuntu.com)
- DevOps.SE: Changing Jenkins port to 80 via systemd (devops.stackexchange.com)
- phoenixNAP: How to change port for Jenkins on Linux (phoenixnap.com)
- Medium: Change default Jenkins port on RHEL/CentOS (medium.com)
- StackOverflow: Change Jenkins default port in Ubuntu 12.04 (stackoverflow.com)
- Community Jenkins forum: systemd failing to launch Jenkins (community.jenkins.io)
- YouTube: How to change Jenkins default port (JENKINS_PORT segment) (youtube.com)
- Scaler: Changing Jenkins default port guidelines (scaler.com)
- AskUbuntu: Fixing Jenkins port override issues (askubuntu.com)
Top comments (0)