【问题标题】:Connection refused to Git from Ruby连接拒绝从 Ruby 到 Git
【发布时间】:2013-03-15 08:39:36
【问题描述】:

当我尝试将某些内容推送到我的 gitlab 的 geosurvey.git 存储库时,我收到此错误:

git@192.168.31.128:geosurvey.git: /usr/local/lib/ruby/1.9.1/net/http.rb:762!in `initialize': Connection refused(2) (Errno:ECONNREFUSED)
  from /usr/local/lib/ruby/1.9.1/net/http.rb:762:in `open'
  from /usr/local/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
  from /usr/local/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
  from /usr/local/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
  from /usr/local/lib/ruby/1.9.1/net/http.rb:762:in `connect'
  from /usr/local/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
  from /usr/local/lib/ruby/1.9.1/net/http.rb:744:in `start'
  from /home/git/gitlab-shell/lib/gitlab_net.rb:56:in `get'
  from /home/git/gitlab-shell/lib/gitlab_net.rb:17:in `allowed?'
  from /home/git/gitlab-shell/lib/gitlab_shell.rb:51:in `validate_access'
  from /home/git/gitlab-shell/lib/gitlab_shell.rb:21:in `exec'
  from /home/git/gitlab-shell/lib/gitlab_shell.rb:16:in `<main>'

上面的错误是针对这段代码的:

def connect
      D "opening connection to #{conn_address()}..."
      s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }
      D "opened"
      if use_ssl?
        ssl_parameters = Hash.new
        iv_list = instance_variables
        SSL_ATTRIBUTES.each do |name|
          ivname = "@#{name}".intern
          if iv_list.include?(ivname) and
             value = instance_variable_get(ivname)
            ssl_parameters[name] = value
          end
        end
        @ssl_context = OpenSSL::SSL::SSLContext.new
        @ssl_context.set_params(ssl_parameters)
        s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
        s.sync_close = true
end

我的 gitlab.yml 或 /etc/nginx/sites-available/gitlab 可能有问题吗?

谢谢,


问题是我无法与远程 gitlab 服务器建立 ssh 连接。我的 ssh 端口是 22(默认),我的 gitlab 端口是 3222。

【问题讨论】:

  • 这就是它所说的,它无法连接。没有任何代码或配置,没有人可以回答这个问题,它可能是任何东西。
  • 不要使用图像来显示错误(或代码,有些人会这样做)。 Stack Overflow 的部分价值在于它是可搜索的。图片打破了这一点,降低了你的问题的价值。
  • 对不起,我不知道。

标签: ruby git gitlab


【解决方案1】:

gitlab的安装指南中缺少必须如何配置监听端口。

现在,有了这行代码,我可以推送和克隆任何存储库。

listen *:80 default_server;         # e.g., listen 192.168.1.1:80;

【讨论】:

  • 优秀。我的回答是关于 ssh,但如果 Apache 服务器配置不正确,我想您确实会收到相同的错误消息。 +1
  • 感谢您的帮助! gitlab的安装指南有错误。 Gitlab 使用 nginx 服务器来部署应用程序。
  • 刚刚意识到我在上一条评论中提到了 +1 ......实际上并没有支持你的答案。所以现在 +1。
  • 你能告诉我们女巫文件中的这一行吗?
【解决方案2】:

问题是我无法与远程 gitlab 服务器建立 ssh 连接。我的 ssh 端口是 22(默认),我的 gitlab 端口是 3222。

那么你需要确保在使用 ssh Gitlab url 时使用端口 3222。
您可以在配置文件中指定自定义端口号,如this question,也可以在“Using a remote repository with non-standard port”中说明,scp 样式。
或者直接在 ssh url 中指定端口:

ssh://[user@]host.xz[:port]/path/to/repo.git/

【讨论】:

    猜你喜欢
    • 2016-12-26
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-06
    • 1970-01-01
    相关资源
    最近更新 更多