I installed Jenkins on a Ubuntu 18.04 ec2 instance by following its official guide.

I want to change Jenkins from port 8080 (default) to port 80.

According to its official document:

If your /etc/init.d/jenkins file fails to start Jenkins, edit the /etc/default/jenkins to replace the line ----HTTP_PORT=8080---- with ----HTTP_PORT=8081---- Here, "8081" was chosen but you can put another port available.

I managed to changed it to port 8081 but when I used port 80, it simply doesn't work:

curl -i localhost:80 returns connection refused

sudo systemctl status jenkins gives

jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Thu 2019-02-21 08:14:55 UTC; 4min 12s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6143 ExecStop=/etc/init.d/jenkins stop (code=exited, status=0/SUCCESS)
  Process: 6212 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)

Feb 21 08:14:53 ip-172-31-11-10 systemd[1]: Starting LSB: Start Jenkins at boot time...
Feb 21 08:14:53 ip-172-31-11-10 jenkins[6212]: Correct java version found
Feb 21 08:14:53 ip-172-31-11-10 jenkins[6212]:  * Starting Jenkins Automation Server jenkins
Feb 21 08:14:53 ip-172-31-11-10 su[6257]: Successful su for jenkins by root
Feb 21 08:14:53 ip-172-31-11-10 su[6257]: + ??? root:jenkins
Feb 21 08:14:53 ip-172-31-11-10 su[6257]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Feb 21 08:14:54 ip-172-31-11-10 su[6257]: pam_unix(su:session): session closed for user jenkins
Feb 21 08:14:55 ip-172-31-11-10 jenkins[6212]:    ...done.
Feb 21 08:14:55 ip-172-31-11-10 systemd[1]: Started LSB: Start Jenkins at boot time.

I am sure nothing runs on port 80.

What am I doing wrong?

  • 2
    On linux, only root can open ports under 1024, but there's workaround explained here on superuser – Tensibai Feb 21 '19 at 8:51
  • Thank you. I'm really nervous when things that look like it should work doesn't. Given this situation, can you show me the troubleshoot steps you would do? I tried sudo systemctl status jenkins and the status reports Jenkins' state is active (exited) with a green dot. I just don't know how to troubleshoot these incidents in the future. – Tran Triet Feb 21 '19 at 8:59
  • 1
    Check Jenkins logs, you should have a /var/log/jenkins/jenkins.log which should show the startup error as unable to bind to (or a different IP) – Tensibai Feb 21 '19 at 9:05
  • Thank you very much. I checked the log file and indeed there is a line Caused by: java.net.SocketException: Permission denied. It doesn't specifically says sth like unable to bind to ... but I guess it's the same, though it's a bit harder for me to guess if the error log is like this. – Tran Triet Feb 21 '19 at 9:25

Assuming you are okay with moving your Jenkins(and settings) to a docker environment, you can do the following. This would give you the advantage to change ports(and manage jenkins) with greater ease in the future without ever having to touch IP tables or load balancers.

Host your Jenkins on a docker container and map the port 80 on your docker host daemon to 8080 on the container.

You can find the latest jenkins docker image here - https://hub.docker.com/_/jenkins

Install docker daemon and download the image using docker pull jenkins

You can use docker run command to start jenkins along with the -p argument to supply port values.

For instance, you are hosting your docker daemon on, then you use this to start Jenkins docker run -t container_tag -p 80:8080 image_name

And then to browse jenkins, use

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.