【问题标题】:Jenkins refused to connect on port 8080 [closed]詹金斯拒绝连接端口 8080 [关闭]
【发布时间】:2017-07-01 07:01:13
【问题描述】:

我在 Ubuntu 服务器上配置了 Jenkins,近 2 个月以来一切正常,Jenkins 正在构建作业并运行测试用例。但是最近我增加了测试用例的数量。一段时间后,当我通过网络浏览器打开 Jenkins 时,它开始拒绝连接。

IP:8080 给出错误“连接被拒绝”。

我尝试通过以下方式重启 Jenkins 服务:

sudo service jenkins restart

它正常重启了,但是jenkins还是没有在浏览器上打开。

然后我在/etc/default/jenkins查看了jenkins的默认设置:

# defaults for jenkins continuous integration server
# pulled in from the init script; makes things easier.
NAME=jenkins

# location of java
JAVA=/usr/bin/java

# arguments to pass to java
JAVA_ARGS="-Djava.awt.headless=true"  # Allow graphs etc. to work even when an X server is present
JAVA_ARGS="-Xmx1024m"
#JAVA_ARGS="-Djava.net.preferIPv4Stack=true" # make jenkins listen on IPv4 address

PIDFILE=/var/run/$NAME/$NAME.pid

# user and group to be invoked as (default to jenkins)
JENKINS_USER=$NAME
JENKINS_GROUP=$NAME

# location of the jenkins war file
JENKINS_WAR=/usr/share/$NAME/$NAME.war

# jenkins home location
JENKINS_HOME=/var/lib/$NAME

# set this to false if you don't want Hudson to run by itself
# in this set up, you are expected to provide a servlet container
# to host jenkins.
RUN_STANDALONE=true

# log location.  this may be a syslog facility.priority
JENKINS_LOG=/var/log/$NAME/$NAME.log
#JENKINS_LOG=daemon.info

# OS LIMITS SETUP
#   comment this out to observe /etc/security/limits.conf
#   this is on by default because http://github.com/jenkinsci/jenkins/commit/2fb288474e980d0e7ff9c4a3b768874835a3e92e
#   reported that Ubuntu's PAM configuration doesn't include pam_limits.so, and as a result the # of file
#   descriptors are forced to 1024 regardless of /etc/security/limits.conf
MAXOPENFILES=8192

# set the umask to control permission bits of files that Jenkins creates.
#   027 makes files read-only for group and inaccessible for others, which some security sensitive users
#   might consider benefitial, especially if Jenkins runs in a box that's used for multiple purposes.
#   Beware that 027 permission would interfere with sudo scripts that run on the master (JENKINS-25065.)
#
#   Note also that the particularly sensitive part of $JENKINS_HOME (such as credentials) are always
#   written without 'others' access. So the umask values only affect job configuration, build records,
#   that sort of things.
#
#   If commented out, the value from the OS is inherited,  which is normally 022 (as of Ubuntu 12.04,
#   by default umask comes from pam_umask(8) and /etc/login.defs

# UMASK=027

# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080


# servlet context, important if you want to use apache proxying  
PREFIX=/$NAME

# arguments to pass to jenkins.
# --javahome=$JAVA_HOME
# --httpPort=$HTTP_PORT (default 8080; disable with -1)
# --httpsPort=$HTTP_PORT
# --argumentsRealm.passwd.$ADMIN_USER=[password]
# --argumentsRealm.roles.$ADMIN_USER=admin
# --webroot=~/.jenkins/war
# --prefix=$PREFIX

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"

这个文件中的一切似乎都很好,war 文件也在给定位置。

当我重新启动服务器 3-4 次时,它又开始打开了。但是这个问题仍然一次又一次地出现。每次打开Jenkins都要重启服务器。

谁能帮我找出这个问题并告诉我如何解决它。

【问题讨论】:

  • 可能是java虚拟机内存不足或堆栈空间不足。日志说了什么。
  • 我认为这是服务器资源问题,您是否有一些关于该问题发生时的上下文?
  • 你设置了管理Jenkins配置系统Jenkins位置詹金斯网址正确吗?如果这不匹配,我已经看到与您类似的行为。
  • 续:如果您没有访问权限,请参阅<Your Jenkins installation>/jenkins.model.JenkinsLocationConfiguration.xml
  • 嗨 mbieren,我也面临堆空间的问题。但我不认为这是内存不足的问题,因为在重新启动分配给它的 Jenkins 内存后应该刷新

标签: linux jenkins


【解决方案1】:

我在 AWS EC2 上运行 Jenkins 时收到此错误,并尝试从外部访问它(在我的例子中是来自内部网络的实例)。

当我从 Jenkins 服务器内部运行 curl localhost:8080 时,一切都很好,但是当我从内部网络中的实例执行相同操作时,我得到了提到的 refused to connect on port 8080 错误。

解决方案是 vim /etc/sysconfig/jenkins 并更改:

JENKINS_LISTEN_ADDRESS="127.0.0.1"

收件人:

JENKINS_LISTEN_ADDRESS="0.0.0.0"

【讨论】:

    【解决方案2】:

    我花了一段时间才弄清楚这一点。对我来说,它是在更改我的 Windows 密码后开始发生的。解决方案是更新 Jenkins 服务的凭据。

    1. 在 Windows 搜索栏中,键入 services 然后输入。
    2. 然后向下滚动到 Jenkins 并双击它。
    3. 在 Jenkins 属性中,选择“登录”选项卡。
    4. 选中“此帐户”复选框
    5. 更新您的用户名和密码。

    瞧!现在 Jenkins web 可以通过 Jenkins 服务连接到 Jenkins 机器了。

    【讨论】:

    • Windows 凭据究竟对在 Ubuntu 上运行 Jenkins 的 Linux 机器有何影响?顺便说一句,检查 OP 对他们自己问题的最后评论 - 他们解决了这个问题,这与您的解决方案无关......
    【解决方案3】:

    运行:

    systemctl stop firewalld.service
    

    再试一次

    【讨论】:

    • 你是认真的吗? “无法连接到 Jenkins?只需禁用防火墙”。这不是解决方案。太可怕了。
    猜你喜欢
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 2013-08-12
    • 2013-03-28
    相关资源
    最近更新 更多