Errno::ECONNREFUSED(无法打开到 :80 的 TCP 连接(连接被拒绝 - connect(2) 用于 nil 端口 80))

Errno::ECONNREFUSED (Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80))

我正在尝试使用库 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 中的相同代码时,我没有收到任何错误。我不知道这是否有帮助,但我 运行ning 的系统是 Linux Mint 18.3 Cinnamon 64 位。

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