DEV Community

Cover image for 🚦Tired of Port Collisions? How I Shifted Jenkins Off 8080 to 9595 (Ubuntu)
Khuram Murad
Khuram Murad

Posted on

🚦Tired of Port Collisions? How I Shifted Jenkins Off 8080 to 9595 (Ubuntu)

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

  1. Changing /etc/default/jenkins had no effect. I set:
   HTTP_PORT=9595
Enter fullscreen mode Exit fullscreen mode

restarted Jenkins, but:

   ps aux | grep jenkins
Enter fullscreen mode Exit fullscreen mode

still showed --httpPort=8080 (stackoverflow.com).

  1. 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 honors JENKINS_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/
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Add these lines:

[Service]
Environment="JENKINS_PORT=9595"
Enter fullscreen mode Exit fullscreen mode

Why JENKINS_PORT? The official systemd unit template reads this variable when starting Jenkins, unlike HTTP_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
Enter fullscreen mode Exit fullscreen mode

This makes systemd pick up your new override (jenkins.io).

4. Verify the new port

sudo ss -tuln | grep 9595
ps aux | grep jenkins
Enter fullscreen mode Exit fullscreen mode

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 entire ExecStart (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

  1. Confirm override file exists:
   ls -l /etc/systemd/system/jenkins.service.d/override.conf
Enter fullscreen mode Exit fullscreen mode
  1. Inspect its contents:
   cat /etc/systemd/system/jenkins.service.d/override.conf
Enter fullscreen mode Exit fullscreen mode
  1. Reload & restart:
   sudo systemctl daemon-reload
   sudo systemctl restart jenkins
Enter fullscreen mode Exit fullscreen mode
  1. Verify the port:
   sudo ss -tuln | grep 9595
   ps aux | grep jenkins
Enter fullscreen mode Exit fullscreen mode

🚀 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=…" alongside JENKINS_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

  1. Changelog for Jenkins systemd overrides — Jenkins official docs (jenkins.io)
  2. Ask Ubuntu: Changed Jenkins port doesn’t apply (askubuntu.com)
  3. DevOps.SE: Changing Jenkins port to 80 via systemd (devops.stackexchange.com)
  4. phoenixNAP: How to change port for Jenkins on Linux (phoenixnap.com)
  5. Medium: Change default Jenkins port on RHEL/CentOS (medium.com)
  6. StackOverflow: Change Jenkins default port in Ubuntu 12.04 (stackoverflow.com)
  7. Community Jenkins forum: systemd failing to launch Jenkins (community.jenkins.io)
  8. YouTube: How to change Jenkins default port (JENKINS_PORT segment) (youtube.com)
  9. Scaler: Changing Jenkins default port guidelines (scaler.com)
  10. AskUbuntu: Fixing Jenkins port override issues (askubuntu.com)

Top comments (0)