For my next phase of learning Rails, I’ve decided to go through all the free guides on the Rails website. I’ll write more about them once I complete the first “Getting Started” guide, but in order to use these guides I first had to actually install Rails. I know what you’re thinking… “Just type $ gem install rails into terminal, what’s the issue?”

Well, China’s the issue. More specifically, the Great Firewall. This isn’t anything new to westerners here, we just use a VPN (Virtual Private Network) to access essential sites like Facebook, Google, Instagram, and Netflix.

Unfortunately just turning on your VPN and and entering $ gem install rails doesn’t work. You’ll get this error message:

$ gem install rails
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNRESET: Connection reset by peer - SSL_connect (

Or this one:

$ gem install rails
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ETIMEDOUT: Operation timed out - connect(2) for "" port 443 (

Or the terminal marker will just hang there and you won’t get any response or error message.

So, with or without a VPN the install won’t work. It turns out the solution is more nuanced than I thought. The database for Rails and other Ruby gems are stored on Amazon S3, which is of course blocked by the Great Firewall. I found this great Chinese website that explains how to install Rails, bundle, and other gemfiles using a mirrored database stored in (which also happens to essentially be the Amazon of China).

The trick is to switch the source of the install from Amazon to Taobao. Here’s how:

$ gem sources --add --remove added to sources removed from sources

Now, check your source:

$ gem sources -l

Finally, with your VPN turned off, $ gem install rails. That should do the trick! Welcome aboard!