Ruby On Rails: Error while bundling gems

I encountered this error when I created a new rails application and tried to bundle the gems.

Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Gem::RemoteFetcher::FetchError: Errno::ECONNREFUSED: Connection refused - connect(2) for "rubygems.org" port 443 (https://rubygems.org/gems/rake-10.4.2.gem)
An error occurred while installing rake (10.4.2), and Bundler cannot
continue.
Make sure that `gem install rake -v '10.4.2'` succeeds before bundling
Advertisements