I want to send a POST/GET from a Rails application to a specific address. However, when I run the application, I got the error: “No connection could be made because the target machine actively refused it. – connect(2)” Below are my codes:
def show
@uri = URI('example.com/getuser?user=bob&email=bob84@gmail.com')
@profile = Net::HTTP.get(@uri)
puts @profile
end
I’m marking this as a reply in order to make it more readable for people who might come here in the future. This was first replied in the comments.
The problem was that
URIisn’t HTTP-centric. So the protocol needs to be specified.The following works :