"No connection could be made" to GitHub - ruby

I am trying to get this run to my test organization created on github.com, but got this error. Can anyone tell me what's wrong?
C:\Workspace\Ruby>set GITHUB_TOKEN=xxx
C:\Workspace\Ruby>set GITHUB_API_ENDPOINT=http://api.github.com
C:\Workspace\Ruby>ruby team_audit.rb HudsonsBay
C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:879:in `initialize': No connection could be made because the target machine actively refused it. - connect(2) for "api.github.com" port 80 (Faraday::Conn
ectionFailed)
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:879:in `open'
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/timeout.rb:75:in `timeout'
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:878:in `connect'
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:852:in `start'
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:1375:in `request'
from C:/Tools/Ruby21-x64/lib/ruby/2.1.0/net/http.rb:1133:in `get'
from C:/Tools/Ruby21-x64/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http
.rb:80:in `perform_request'
from C:/Tools/Ruby21-x64/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http
.rb:40:in `block in call'
from C:/Tools/Ruby21-x64/lib/ruby/gems/2.1.0/gems/faraday-
C:\Workspace\Ruby>

I tried to make the same request and got the same error.
after changing the URL from http://api.github.com into https://api.github.com it working.

Related

Watir - No connection could be made because the target machine actively refused it. - connect(2) for "127.0.0.1" port 9518

I'm a newbie in ruby and watir. I'm trying to run the following lines:
require 'watir-webdriver'
b = Watir::Browser.new :chrome
b.goto 'https://www.google.co.in/'
Chrome is opened, but the browser doesn't get google page. I get the following error:
Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2) for "127.0.0.1" port 9518
from C:/Ruby22-x64/lib/ruby/2.2.0/net/http.rb:879:in `initialize'
from C:/Ruby22-x64/lib/ruby/2.2.0/net/http.rb:879:in `open'
from C:/Ruby22-x64/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
from C:/Ruby22-x64/lib/ruby/2.2.0/timeout.rb:73:in `timeout'
from C:/Ruby22-x64/lib/ruby/2.2.0/net/http.rb:878:in `connect'
from C:/Ruby22-x64/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
from C:/Ruby22-x64/lib/ruby/2.2.0/net/http.rb:852:in `start'
from C:/Ruby22-x64/lib/ruby/2.2.0/net/http.rb:1375:in `request'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/http/default.rb:103:in `response_for'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/http/default.rb:57:in `request'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/bridge.rb:653:in `raw_execute'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/bridge.rb:631:in `execute'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/bridge.rb:136:in `get'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/common/navigation.rb:32:in `to'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.3/lib/watir-webdriver/browser.rb:77:in `goto'
from (irb):17
from C:/Ruby22-x64/bin/irb:11:in `<main>'
I looked for other topics and Q&A but I didn't found bright answer.

ruby: ECONNREFUSED from http.rb

I am trying to parse an rss feed with Ruby. This is my (working) code, with the actual feed url:
include 'rss'
myfeed = RSS::Parser.parse('http://allmusicnews.altervista.org/blog/feed/', false)
If I run it from my development computer (Mac OS 10.9), all works fine. If I run it from my server (Debian 7), all i get is:
/home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:879:in `initialize': Connection refused - connect(2) for "allmusicnews.altervista.org" port 80 (Errno::ECONNREFUSED)
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:879:in `open'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:878:in `connect'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:852:in `start'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:318:in `open_http'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:736:in `buffer_open'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:211:in `block in open_loop'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:209:in `catch'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:209:in `open_loop'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:150:in `open_uri'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:716:in `open'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/open-uri.rb:724:in `read'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rss/parser.rb:103:in `normalize_rss'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rss/parser.rb:89:in `initialize'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rss/parser.rb:76:in `new'
from /home/daniele/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rss/parser.rb:76:in `parse'
This does not happen with other rss feeds. example: feeds.blogo.it/soundsblog/it seems working well on both platforms.
I am using the same Ruby version (2.2.0), installed with RVM on both the computers. Same gems too.
Any clue, at least about what to look for?
ps: it may seem something related to connection timeout, but as I run my script suddenly I see the error message above, there's no idle waiting time...
Please ignore my question. I was shooting to the wrong target.
Actually I'm afraid to have some blacklistish problem with my production machine. I cannot connect to altervista.org server in any way (lynx, telnet), I keep getting "connection refused error", so there's nothing to do with my Ruby code...

when i do knife cookbook upload 'cookbookname'

knife cookbook upload 'cookbookname'
i am getting the following error.
ubuntu#mychefclient:~/chef-repo$ knife cookbook upload redis
Uploading redis [0.1.0]
/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `initialize': getaddrinfo: Temporary failure in name resolution (SocketError)
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `open'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `block in connect'
from /opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:69:in `timeout'
from /opt/chef/embedded/lib/ruby/1.9.1/timeout.rb:100:in `timeout'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:763:in `connect'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:756:in `do_start'
from /opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/resource.rb:76:in `put'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/cookbook_uploader.rb:151:in `block in uploader_function_for'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/cookbook_uploader.rb:25:in `call'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/cookbook_uploader.rb:25:in `block (3 levels) in setup_worker_threads'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/cookbook_uploader.rb:24:in `loop'
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.2/lib/chef/cookbook_uploader.rb:24:in `block (2 levels) in setup_worker_threads'
This is happening because knife cannot access the Chef Server. Please ensure you can access the server (try pinging and telneting). It is most likely a local network issue.

Error when running net/http in ruby via the terminal

Running a Net::HTTP post request in ruby. I am using the terminal in Ubuntu and receive this error message:
SocketError: getaddrinfo: Name or service not known
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `initialize'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `open'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from /usr/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from /usr/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from /usr/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /usr/lib/ruby/1.9.1/net/http.rb:744:in `start'
from /usr/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /usr/lib/ruby/1.9.1/net/http.rb:1307:in `send_entity'
from /usr/lib/ruby/1.9.1/net/http.rb:1096:in `post'
from (irb):356
from /usr/bin/irb:12:in `<main>'
Running the following code:
uri = ##url
http = Net::HTTP.new(uri)
response = http.post('/', ##str)
puts response
"Name or service not known" is a socket level error that is thrown when you cannot resolve a given domain name or are specifying an IP address that cannot be connected to. No other information will be available without posting the URL and string you are trying to post.

With Nokogiri i am getting error "initialize': getaddrinfo: No such host is known. (SocketError)"

I worte the below code, just to start the Nokogiri to mee the requirement and when I ran it for testing got the error:
D:\WIPData\Ruby\Scripts>Nokogiri.rb
C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `initialize': getaddrinfo: No such
host is known. (SocketError)
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `open'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:744:in `start'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:306:in `open_http'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:775:in `buffer_open'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:203:in `block in open_loop'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:201:in `catch'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:201:in `open_loop'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:146:in `open_uri'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:677:in `open'
from C:/Ruby193/lib/ruby/1.9.1/open-uri.rb:33:in `open'
from D:/WIPData/Ruby/Scripts/Nokogiri.rb:6:in `<main>'
D:\WIPData\Ruby\Scripts>
CODE
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML::Document for the page we’re interested in...
doc = Nokogiri::HTML(open('http://www.google.co.in'))
Why so and how to fix the same,please advice me.
It appears you need to configure a proxy. Find out what the proxy URL/Port is for your organization (and whether there needs to be authentication). You may be able to view this information from your browser configuration. In order to use it with your Ruby code, you need to set the HTTP_PROXY environment variable.
You can set it in Ruby code:
ENV['HTTP_PROXY'] = 'http://hostname:port'
or if you need authentication:
ENV['HTTP_PROXY'] = 'http://username:password#hostname:port'
A more permanent solution is to set HTTP_PROXY in your system environment variables.

Resources