There are sometimes intermittent connectivity issues between us and other services on the internet. Every package manager server will experience some downtime. Even if you can make a connection to them, their servers can fail in satisfying your request. This includes npm and yarn, bundler, rubygems, pip, maven, composer, cocoapods, and the Android SDK. We've had customers report network and server issues with all these tools. There is not much that we can do to mitigate this except let the service owners know.
When you start seeing non-deterministic/flaky failures in your dependency setup, we suggest caching as many things as possible. In most cases when you push code, you want to test your team or company's work, not network connections and third party servers.
In some cases, you may specifically want to test that your application can fetch all of its dependencies fresh, or update your dependencies and run your test suite against them. For this, we suggest making a separate branch or job type specifically. Users may also run this as a scheduled workflow.
For more information, see: https://circleci.com/docs/2.0/caching/