edit HTTP_PORT in config file:
sudo nano /etc/default/jenkins
# update
# HTTP_PORT=1234
# set any port you want
If this doesn't resolve the issue,
set the port in jenkins.service file:
sudo nano /lib/systemd/system/jenkins.service
# update
# Environment="JENKINS_PORT=1234"
# set any port you want
sudo nano /etc/systemd/system/jenkins.service.d/override.conf
# update
# Environment="JENKINS_PORT=1234"
# set any port you want
Then restart the service by:
sudo systemctl daemon-reload
sudo systemctl restart jenkins.service
# check status by:
sudo systemctl status jenkins.service
Note: to check if a port is available to use, run:
sudo lsof -i -P -n | grep 'port_number'
# no result will show if port_number is not being used.