Search code examples
rubyhttphttparty

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


I'm trying to use the library HTTParty, but whenever I run the code below I receive an error.

Code:

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

When I run the code I receive the error: Errno::ECONNREFUSED (Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80)). I don't get any error when I run the same code in net/http. I don't know if this helps, but the system I'm running is Linux Mint 18.3 Cinnamon 64-bit .


Solution

  • I know that this is late, but using https://example.com instead of http://example.com was the solution to my problem.