Errno::ECONNREFUSED(无法打开到 :80 的 TCP 连接(连接被拒绝 - connect(2) for nil port 80))

Pra*_*al1 7 ruby http httparty

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

代码:

require 'httparty'
response = HTTParty.get('http://example.com')
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,我收到错误: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 。

Pra*_*al1 10

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

  • 未来的我们永远不会迟到,这对我帮助很大 (8认同)
  • 帮助了我 - 我是个白痴,完全忘记了协议:D (2认同)