【发布时间】: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')吗? -
我没有在本地服务器上运行它,而只是在我的笔记本电脑上运行。