【问题标题】:Errno::ECONNREFUSED (Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80))Errno::ECONNREFUSED(无法打开到 :80 的 TCP 连接(连接被拒绝 - connect(2) 用于 nil 端口 80))
【发布时间】:2018-11-15 01:41:43
【问题描述】:

我正在尝试使用库 HTTParty,但每当我运行下面的代码时都会收到错误消息。

代码:

require 'httparty'
response = HTTParty.get('http://example.com')

当我运行代码时,我收到错误:Errno::ECONNREFUSED (Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80))。 当我在net/http 中运行相同的代码时,我没有收到任何错误。我不知道这是否有帮助,但我正在运行的系统是 Linux Mint 18.3 Cinnamon 64-bit 。

【问题讨论】:

  • 您是从本地服务器运行它吗?在应用程序的上下文中?你能发布完整的回溯错误吗?你也试过response = HTTParty.get('https://example.com') 吗?
  • 我没有在本地服务器上运行它,而只是在我的笔记本电脑上运行。

标签: ruby http httparty


【解决方案1】:

我知道这已经很晚了,但是使用 https://example.com 而不是 http://example.com 是我的问题的解决方案。

【讨论】:

  • 对未来的我们来说永远不会迟到,它帮助了我很多
  • 帮助了我——我是个白痴,完全忘记了协议:D
猜你喜欢
  • 2012-04-01
  • 2016-08-13
  • 2016-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-16
  • 2020-02-21
相关资源
最近更新 更多