Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"gem install rails" fails with DNS error

Tags:

$ rvm use Using /home/owner/.rvm/gems/ruby-2.1.2 $ gem install rails ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)     Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 80 (http://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/thread_safe-0.3.4.gemspec.rz) $ gem update --system ... $ gem -v 2.4.1 $ gem install rails ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)     Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 80 (http://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/rails-4.1.5.gemspec.rz) 

I have attempted:

  1. Installing other gems (devise, activerecord). I get the same error.
  2. Reinstalling RVM
  3. Running gem update --system
  4. Setting static DNS to google's 8.8.8.8 and 8.8.4.4
  5. Adding https://production.cf.rubygems.org as a gem source (see below for error)
  6. Installing 14.04 over my previous 12.04. Error persists. The source of the error must be outside my computer.

Additional information about my connection:

  1. I can connect to https://rubygems.org/ through my browser
  2. My modem's firewall is completely disabled.
  3. $ curl -v --head https://rubygems.org output: http://pastebin.com/ca6DAvaU

My /etc/resolv.conf

$ cat /etc/resolv.co # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver 75.75.75.75 search home.network 

Add direct gem source

Ref: https://stackoverflow.com/a/19299266/3993020

owner@owner-Z87X-UD3H:~$ gem sources --add https://production.cf.rubygems.org Error fetching https://production.cf.rubygems.org:     Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443 (https://your-dns-needs-immediate-attention.network/specs.4.8.gz) 

Additional debug information for gem install rails

owner@owner-Z87X-UD3H:~$ gem install rails --debug -V NOTE:  Debugging mode prints all exceptions even when rescued Exception `LoadError' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/resolv.rb:169 - LoadError HEAD https://api.rubygems.org/api/v1/dependencies Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block 200 OK GET https://api.rubygems.org/api/v1/dependencies?gems=rails Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block 200 OK Exception `Resolv::DNS::Config::NXDomain' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/resolv.rb:547 - _rubygems._tcp.api.rubygems.org Exception `Errno::ECONNREFUSED' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879 - Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443 Exception `Gem::RemoteFetcher::FetchError' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/remote_fetcher.rb:286 - Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443 (https://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/rails-4.1.5.gemspec.rz) ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)     Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443 (https://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/rails-4.1.5.gemspec.rz)     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/remote_fetcher.rb:286:in `rescue in fetch_path'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/remote_fetcher.rb:259:in `fetch_path'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/source.rb:146:in `fetch_spec'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/resolver/api_specification.rb:76:in `spec'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/resolver/installer_set.rb:77:in `add_always_install'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency_installer.rb:461:in `resolve_dependencies'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:238:in `install_gem'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:299:in `block in install_gems'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:295:in `each'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:295:in `install_gems'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:202:in `execute'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/command.rb:307:in `invoke_with_build_args'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:168:in `process_args'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:138:in `run'     /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:54:in `run'     /home/owner/.rvm/rubies/ruby-2.1.2/bin/gem:21:in `<main>' 
like image 873
tmtmtmtmt Avatar asked Aug 30 '14 15:08

tmtmtmtmt


People also ask

How do I install gem packages?

With the --local ( -l ) option, you would perform a local search through your installed gems. To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs.

What does gem install Rails do?

gem install bundler installs a gem(library) that will help you to manage your project dependencies. Then you have a project that contains a file called Gemfile , when you cd into that directory and enter bundle install it will install all gems needed for that project.

What is Ruby gem ActiveRecord?

ActiveRecord is a gem that is part of Ruby on Rails. It is the ORM, i.e. the library that maps our objects to tables. In other words, it is the Ruby library that allows us to use Ruby classes in order to access our data stored in an RDBMS, like MySQL or PostgreSQL.

How do I push a gem to RubyGems?

From the main menu, select Tools | Gem | Push Gem. In the Run tool window, specify your RubyGems credentials. Your gem will be published to RubyGems.org.


2 Answers

Like blasio pointed out. It seems like the Xfinity modems are setting up the search domain to home.network and this is messing things up for the reasons he mentioned (essentially, home.network is now a valid domain name that the modems are trying to contact before making a connection).

I had the same problem and the modification on resolv.conf seem to do the trick, and that should probably be an accepted solution for linux environments. I had this problem while attempting this on a virtual machine running ubuntu, and my host(OSX Mavericks) was passing down the search home.network like the modem is, so I wanted to see if I could find a solution that could be done at the host OS level because the same problem happened when I attempted gem install rails on my OSX terminal.

If you go to the OSX network settings, under DNS you'll see the home.network line under the Search Domains area. After some googling it seems that comcast recently changed this from http://hds1.ma.comcast.net'. I changed it back, restarted and gave gem install rails another shot, which worked with no problem.

Strange issue but this is a better solution that swapping modems or changing gem sources.

like image 192
jalvarado91 Avatar answered Sep 20 '22 17:09

jalvarado91


I had the same issue with Comcast xFinity and Compass.

Update for Windows 7 users:

Go to Control Panel > Network and Sharing Center Under "Active Networks" select "Connections: Local Area Connections" In the "Local Area Connection Status" dialogue box, click on "Properties" Double click the IPv4 item In the "Internet Proptocol Verion 4" icon or click the "Properties" button, then click "Advanced" In the DNS tab, just above the 2nd input box, click the "Append These DNS suffixes (in order)" radio button,     then click "Add", enter "home.lan", then click OK until the dialogue closes.      Many thanks to John Smith for the Vista fix and Somnambulent for Win 8.1 fix. 
like image 22
Bob Rast Avatar answered Sep 19 '22 17:09

Bob Rast