<p>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.</p>

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

<p>You can find the latest jenkins docker image here - <a href="https://hub.docker.com/_/jenkins" rel="nofollow noreferrer">https://hub.docker.com/_/jenkins</a> </p>

<p>Install docker daemon and download the image using
<code>docker pull jenkins</code></p>

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

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

<p>And then to browse jenkins, use <a href="http://10.10.169.69:80/" rel="nofollow noreferrer">http://10.10.169.69:80/</a></p>

CC BY-SA 4.0
2019-02-23T23:01:30.223Z
2019-02-24T00:23:40.903Z
2019-02-24T00:23:40.903Z
KatariaA
<p>I installed Jenkins on a Ubuntu 18.04 ec2 instance by following its official guide.</p>

<p>I want to change Jenkins from port 8080 (default) to port 80.</p>

<p>According to its official document:</p>

<blockquote>
  <p>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.</p>
</blockquote>

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

<p><code>curl -i localhost:80</code> returns <code>connection refused</code></p>

<p><code>sudo systemctl status jenkins</code> gives </p>

<pre><code>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.
</code></pre>

<p>I am sure nothing runs on port 80.</p>

<p>What am I doing wrong?</p>

CC BY-SA 4.0
2019-02-21T08:51:10.193Z
On linux, only root can open ports under 1024, but there's workaround explained [here on superuser](https://superuser.com/questions/710253/allow-non-root-process-to-bind-to-port-80-and-443)
Tensibai
CC BY-SA 4.0
2019-02-21T08:59:32.630Z
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
CC BY-SA 4.0
2019-02-21T09:05:03.110Z
Check Jenkins logs, you should have a /var/log/jenkins/jenkins.log which should show the startup error as unable to bind to 0.0.0.0:80 (or a different IP)
Tensibai
CC BY-SA 4.0
2019-02-21T09:25:01.717Z
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
<jenkins>
How to change Jenkins' port to 80?
Tran Triet
# How to change Jenkins' port to 80?

(Asked by: username_0 on 2019-02-21)

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?

**Tags:** jenkins

> **Comments:**
> **username_1**: On linux, only root can open ports under 1024, but there's workaround explained [here on superuser](https://superuser.com/questions/710253/allow-non-root-process-to-bind-to-port-80-and-443)  
> **username_0**: 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.  
> **username_1**: Check Jenkins logs, you should have a /var/log/jenkins/jenkins.log which should show the startup error as unable to bind to 0.0.0.0:80 (or a different IP)  
> **username_0**: 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.  

---

## 1 answers

### Answer by username_2 on 2019-02-23. Score: 1

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 10.10.169.69, then you use this to start Jenkins
`docker run -t container_tag -p 80:8080 image_name`

And then to browse jenkins, use <http://10.10.169.69:80/>


---

