10

I'm trying to install Jenkins on my web server, which is an Ubuntu 13.10 server running on an Amazon EC2 instance. I've restarted Jenkins using

sudo /etc/init.d/jenkins restart

When I check my processes with

ps aux | grep jenkins

I can see multiple items running with the following descriptions:

jenkins  22356  0.0  0.0  20268   400 ?        S    10:10   0:00 /usr/bin/daemon --name=jenkins --inherit --env=JENKINS_HOME=/var/lib/jenkins --output=/var/log/jenkins/jenkins.log --pidfile=/var/run/jenkins/jenkins.pid -- /usr/bin/java -jar /usr/share/jenkins/jenkins.war --webroot=/var/run/jenkins/war --httpPort=8080 --ajp13Port=-1 --httpListenAddress=127.0.0.1 --ajp13ListenAddress=127.0.0.1 --preferredClassLoader=java.net.URLClassLoader
jenkins  22358  5.9  5.7 1618372 97376 ?       Sl   10:10   0:17 /usr/bin/java -jar /usr/share/jenkins/jenkins.war --webroot=/var/run/jenkins/war --httpPort=8080 --ajp13Port=-1 --httpListenAddress=127.0.0.1 --ajp13ListenAddress=127.0.0.1 --preferredClassLoader=java.net.URLClassLoader

The server doesn't want to allow me to access this installation, so if I visit

x.x.x.x:8080

I just get a "Oops! Google Chrome could not connect" page, not even a HTTP status 404 / 500.

I tried checking /var/log/jenkins/jenkins.log, but it doesn't indicate any problems. Here's the log output after restarting:

Running from: /usr/share/jenkins/jenkins.war
Dec 02, 2013 10:10:07 AM winstone.Logger logInternal
INFO: Beginning extraction from war file
Jenkins home directory: /var/lib/jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Dec 02, 2013 10:10:13 AM winstone.Logger logInternal
INFO: HTTP Listener started: port=8080
Dec 02, 2013 10:10:13 AM winstone.Logger logInternal
INFO: Winstone Servlet Engine v0.9.10 running: controlPort=disabled
Dec 02, 2013 10:10:14 AM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Dec 02, 2013 10:10:14 AM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Dec 02, 2013 10:10:14 AM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Dec 02, 2013 10:10:14 AM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Dec 02, 2013 10:10:14 AM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Dec 02, 2013 10:10:22 AM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
Dec 02, 2013 10:10:23 AM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
Dec 02, 2013 10:10:23 AM hudson.TcpSlaveAgentListener <init>
INFO: JNLP slave agent listener started on TCP port 43315
Dec 02, 2013 10:10:23 AM hudson.WebAppMain$2 run
INFO: Jenkins is fully up and running

I was thinking I could be having a problem with EC2 security groups blocking the port, but my security group assigned to that server has got 8080 port opened for HTTP inbound.

Another check I tried was to SSH into the server, and use Lynx to see if Jenkins is actually serving content. I visited http://localhost:8080 and it was showing the Jenkins page as expected.

Any ideas?

Josef van Niekerk
  • 521
  • 4
  • 8
  • 16

2 Answers2

7

EDIT 2

If running Jenkins on an Amazon EC2 instance, try setting HTTP_HOST to 0.0.0.0. You may not be able to bind the public interface IP directly.


EDIT 1

Check /etc/default/jenkins instead if you installed directly from the .deb package.


It appears Jenkins is listening on localhost (--httpListenAddress=127.0.0.1). In this configuration, Jenkins is not listening for connections from the network interface.

To resolve for Ubuntu, check the contents of /etc/init/jenkins.conf and append --httpListenAddress=x.x.x.x to JENKINS_ARGS (where x.x.x.x is the server's external IP address).

plasmid87
  • 2,118
0

How I Resolved Jenkins Port Access Issues on Port 8080.

Today, I successfully resolved an issue with external access to Jenkins on port 8080. Here's a concise breakdown of the steps I followed:

Step 1: Editing Jenkins Configuration

I edited the Jenkins service configuration to ensure it listened on the correct port and IP address:

sudo systemctl edit jenkins

This opened the drop-in file at /etc/systemd/system/jenkins.service.d/override.conf. I modified the environment variables as follows:

[Service]
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djava.io.tmpdir=/var/cache/jenkins/tmp -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York -Duser.timezone=America/New_York" Environment="JENKINS_OPTS=--pluginroot=/var/cache/jenkins/plugins"

After saving, I restarted Jenkins to apply the changes:

sudo systemctl restart jenkins

Also add the temp directory.

sudo mkdir /var/cache/jenkins/tmp

Step 2: Opening Port 8080 in the Cloud Firewall

Since my server is hosted in the cloud, I opened port 8080 in the relevant security configuration:

AWS: Added an inbound rule for port 8080 in the EC2 Security Group.

Azure: Configured an inbound security rule for the VM.

GCP: Added a firewall rule for the instance.

Oracle Cloud: Opened port 8080 in the Virtual Cloud Network (VCN) security list.

Step 3: Updating iptables

I noticed traffic was still blocked internally. Checking iptables, I realized a REJECT rule was blocking traffic to port 8080. To resolve this, I added an ACCEPT rule at the top of the chain:

sudo iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT sudo iptables-save

Key Takeaways

1: Edit the Jenkins service configuration to ensure it binds to the correct IP/port. 2: Open the required ports in your cloud provider’s security settings. 3: Adjust local firewall rules (iptables) to allow traffic, prioritizing ACCEPT rules above REJECT.

After these adjustments, Jenkins became fully accessible on port 8080.

Dave M
  • 4,494