10

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 .

Practical1
  • 789
  • 1
  • 8
  • 26
  • 3
    are you running this from a local server? in the context of an application? can you post the full backtrace errors? Also did you try with `response = HTTParty.get('https://example.com')` ? – lacostenycoder Nov 15 '18 at 03:15
  • I'm not running this on a local server, but just my laptop computer. – Practical1 Nov 15 '18 at 03:48

1 Answers1

19

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

Practical1
  • 789
  • 1
  • 8
  • 26