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

问题描述 投票:3回答:1

我正在尝试使用库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。

ruby http httparty
1个回答
3
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.