120
votes

I have been trying to do the quickstart guide for react native, but kept getting this error

There appears to be trouble with your network connection. Retrying...

My connection works just fine.

15
I just got this this error when creating a new Vuejs project. My internet speed is 4mb/s and I'm not behind any proxy. The problem was Vuejs was using another registry taobao.org which is very slow. I just deleted the file .vuerc from my home folder and make sure I selected no when Vuejs prompted to use the taobao.org registry.user3502626
In my case, despite passing --network-timeout 100000, turning off Windows Defender, clearing proxy settings, disabling IPv6, and running yarn cache clean --force I get "There appears to be trouble with your network connection. Retrying..." a few times followed by: error An unexpected error occurred: "https://registry.yarnpkg.com/@electron-forge/template-typescript/-/template-typescript-6.0.0-beta.57.tgz: read ECONNRESET" though I can copy/paste this link into a web browser and quickly download without problems. npm install also works... ugjacobq

15 Answers

166
votes

This happens when your network is too slow or the package being installed is too large, and Yarn just assumes it's a network problem. Try increasing Yarn network timeout:

yarn add <yourPackage> --network-timeout 100000
35
votes

Deleting the yarn.lock file and rerunning "yarn install" worked for me.

29
votes

I got this issue because I was working within my company internal network and proxy needed to be set.

$ yarn config set proxy http://my_company_proxy_url:port
$ yarn config set https-proxy http://localhost:3128

example $ yarn config set https-proxy http://proxy.abc.com:8080
20
votes
  1. Could be that your network speed is too slow and timeout is relatively short, you can set yarn install --network-timeout=30000
  2. If you still have the error, could be solved by proxy, vim ~/.yarnrc and add useful proxy setting.
20
votes

Turning off "real time protection" with windows defender fixed it for me.

Sucks but it appears the checks are too much for yarn to handle.

19
votes

Simple working solution (right way of doing it):

Looks like yarn was trying to connect via a proxy. The following worked for me:

npm config rm proxy
npm config rm https-proxy

Source: https://github.com/yarnpkg/yarn/issues/4890

8
votes

Could be a proxy issue. Run the command below to delete the proxy.

yarn config delete proxy
5
votes

The following helped me

yarn config delete https-proxy
yarn config delete proxy

they set your https-proxy and proxy values to undefined. My https-proxy was set to localhost. Check that proxy and https-proxy config values are undefined by using the following

yarn config get https-proxy
yarn config get proxy
5
votes

The large package involved often can be Material Design Icons.

Check if you make use of the Material Design Fonts material-design-icons in your package.json and remove it!

material-design-icons is too big to handle and you should only use material-design-icons-fonts if you only need them.

https://medium.com/@henkjan_47362/just-a-short-notice-for-whomever-is-searching-for-hours-like-i-did-a741d0cd167b

2
votes
yarn config set network-timeout 600000 -g

Often, your error is caused by hitting the network connection time limit, and yarn simply reports there is "trouble with your network connection".

The line of code at the top of my answer sets the global yarn network timeout to 10 minutes.

Having a long network timeout is probably okay, because yarn uses caches and if it's big and you don't have it, you probably want it to just go ahead and take the time to download.

1
votes

Turn off or disable your antivirus before run this command. I am also facing same issue than i disable quick heal antivirus and it is works.

create-react-app my-app
0
votes

I encountered this error while attempting yarn outdated. In my case, a few of the packages in my project were hosted in a private registry within the company network. I didn't realize my VPN was disconnected so it was initially confusing to see the error message whilst I was still able to browse the web.

It becomes quite obvious for those patient enough to wait out all five retry attempts. I, however, ctrl-c'd after three attempts... 😒

0
votes

In my case I found a reference to a defunct registry in my ~/.yarnrc file

When I removed that the error went away

0
votes

This happened in my case trying to run yarn install.

My project is a set of many sub-projects. After a couple of retries, it showed a socket-timeout error log:

error An unexpected error occurred: "https://<myregitry>/directory/-/subProject1-1.0.2.tgz: ESOCKETTIMEDOUT".

I cloned subProject1 separately, did yarn install on it and linked it with main project.

I was able to continue with my command on main project after that. Once done, I unlinked the subProject1 and did a final yarn install --force which was success.

0
votes

When I want to use yarn I have above error, but there is not any error with npm, for this situation you can install react project from npm

npx create-react-app app --use-npm