Yarn - There appears to be trouble with your network connection. Retrying
Asked Answered
H

30

238

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.

Hepner answered 24/7, 2018 at 22:24 Comment(3)
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.Previdi
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... ugObtect
For me the problem was with yarn, i do not know the problem but switching npm just worked.Doviedow
W
319

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
When answered 24/7, 2018 at 22:32 Comment(8)
@SunilGarg doesn't matter what package name. --network-timeout is just a yarn flag that tells it to set the network timeout to that particular value. This can be yarn add react --network-timeout 100000, yarn add @angular/core --network-timeout 100000 or just yarn --network-timeout 100000Vivica
I kept forgetting to add the --network-timeout switch when running yarn, so I added an alias for it to my ~/.bashrc file just after the yarn PATH modification as follows: alias yarn='yarn --network-timeout 100000'Crest
For people like me and @PaulMEdwards, I added another answer that does the network-timeout setting, but sets it globally always. https://mcmap.net/q/116776/-yarn-there-appears-to-be-trouble-with-your-network-connection-retryingMismatch
another useful option is --network=host. In my case is was: docker build --network=host --progress=plain .Gink
May not be an ideal answer, but I just changed from company wifi to mobile hotspot, and it worked. It also worked in the past ...Duong
yarn install --network-timeout=300000 to install all the packages of the projectPlayroom
@Duong not ideal but only works ;) Can't getting how it works, but works. My WiFi connection was really fast 200MB/s, but it was too slow for yarn. When I switched to slowest mobile, yarn was satisfied. ThanksPhlogistic
I encountered this on both yarn add and yarn upgrade, and setting --network-timeout 10000 made no difference; the message was still displayed immediately despite a 100% working connection. I'm inferring that slowness and package size are not the only possible causes for the error.Ultranationalism
J
106

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

Jaundiced answered 5/12, 2019 at 16:41 Comment(3)
This gave me an error using docker-compose build --no-cache: failed to solve: failed to compute cache key: "/yarn.lock" not found: not foundReena
should never ever delete lock files. This defeats the purpose of having them in first place.Recoverable
Yes, pushing a new lock file (yarn.lock, composer.lock ...) will create crazy MR if you have Git and a team, furthermore, it will make your team to the same thing in local, just know what you are doing if you work in a team please.Kaph
C
41

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
Callan answered 14/8, 2018 at 18:20 Comment(1)
Sometimes you might need to pass credentials like: $ yarn config set https-proxy username:password@proxy:portMartine
M
38
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.

Mismatch answered 2/9, 2021 at 23:37 Comment(1)
Thanks. This was yarn add @tabler/icons-react for me. Hope that SEO help someones in the future.Theodore
V
37

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

Veronicaveronika answered 16/7, 2019 at 19:31 Comment(0)
P
37

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.

Ploch answered 2/10, 2019 at 18:4 Comment(4)
Same issue running react-native init on Windows 10 ^^ this fixed itEbullience
Its better to exclude certain directories in windows defender than turning it off each timeEmrich
@Emrich If defender turning off each time is concern then there is option to disable it parentally from windows regeditShaggy
That worked, after disabling real-time protection in security, I was able to install the packages with yarn.Walleyed
M
31
  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.
Montpellier answered 25/3, 2019 at 3:46 Comment(1)
Hi Guys this command really works when you are getting network connection problem in your Mac while doing yarn install even your network connection is good. Thanks!Superannuation
M
16

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
Martine answered 22/9, 2020 at 17:22 Comment(0)
A
13

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

yarn config delete proxy
Aryn answered 30/12, 2019 at 10:36 Comment(0)
F
9

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

Fm answered 9/10, 2020 at 7:44 Comment(1)
Spot on the money for me! I ended up adding separately and it didn't timeout.Metropolitan
A
7

Got the exact issue when trying yarn install

yarn install --network-timeout 100000

Just using this didn't solve my problem. I had to install only ~5 packages at a time. So I ran yarn install multiple times with only few dependencies in the package.json at a time.

Hope this helpful

Apodictic answered 7/8, 2022 at 5:6 Comment(0)
G
3

In short, this is caused when yarn is having network problems and is unable to reach the registry. This can be for any number of reasons, but in all cases, the error is the same, so you might need to try a bunch of different solutions.

Reason 1: Outdated Proxy Settings

This will throw the "network connection" error if you are connected to a network that uses a proxy and you did not update yarn configs with the correct proxy setting.

You can start running the below commands to check what the current proxy configs are set to:

yarn config get https-proxy
yarn config get proxy

If the proxy URLs returned are not what you expect, you just need to run the following commands to set the correct ones:

yarn config set https-proxy <proxy-url>
yarn config set proxy <proxy-url>

Similarly, if you have previously set up the proxy on yarn but are no longer using a network connection that needs a proxy. In this case, you just need to do the opposite and delete the proxy config:

yarn config delete https-proxy
yarn config delete proxy

Reason 2: Incorrect Domain name resolution

This will throw the "network connection" error if for whatever reason your machine cannot resolve your yarn registry URL to the correct IP-address. This would usually only happen if you (or your organization) are using an in-house package registry and the ip-address to the registry changes.

In this case, the issue is not with yarn but rather with your machine. You can solve this by updating your hosts file (for mac users, this should be found in '/etc/hosts') with the correct values, by adding a mapping as follows:

<ip-address> <registry-base-url>

example:

10.0.0.1 artifactory.my.fancy.organiza.co.za
Garage answered 22/9, 2021 at 16:56 Comment(0)
C
2

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
Condemn answered 16/9, 2021 at 10:48 Comment(1)
Not sure if this has any unintended side effects but it works.Bradleybradly
R
2

If you are working within a docker environment or elsewhere that might need a different approach where you are not modifying the installation process, try adding a file named .yarnrc in the root of the project with the problem (where your package.json resides) and in that file write:

network-timeout 600000

Docker will still run without modifying the docker-compose.yml file and you get the timeout solution.

Reena answered 6/5, 2022 at 12:47 Comment(0)
D
2

In my case it was Window's real-time protection which was causing the issue. Turn off the Real-time protection till your package is installed. Then turn it ON.

enter image description here

Derringdo answered 15/8, 2023 at 9:15 Comment(0)
A
1

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... 😒

Alfaro answered 21/11, 2020 at 2:10 Comment(0)
H
1

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
Halvah answered 4/6, 2021 at 0:27 Comment(0)
S
1

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

When I removed that the error went away

Sustenance answered 28/7, 2021 at 10:49 Comment(0)
J
1

Deleting the yarn-lock file, doing a yarn cache clean and then a yarn solved my issue

Jaffe answered 19/10, 2021 at 23:2 Comment(1)
The idea behind the lock file is to have reproducible installs across different machines. So one should keep in mind that this might have (maybe small) side effects.Hourly
E
1
npm install 

worked for me (but my project was built with yarn)

Entoblast answered 3/11, 2021 at 10:10 Comment(3)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewMali
Nothing worked for me, so I am back to npm installGatias
This works for me too, my project was built with yarn, but after a long time, now yarn reports network error.Noleta
G
1

Adding option --network=host was the solution in my case.

docker build --network=host --progress=plain .

Gink answered 18/5, 2022 at 14:9 Comment(1)
That's it, in my case had to set the docker-compose network to driver: host, thanks a lot 🙏Clerk
U
0

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.

Unconcerned answered 25/8, 2021 at 7:31 Comment(0)
D
0

I got this error while trying to run yarn install - i use WSL with ubuntu distro, the following command fixed it,

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

Devaluate answered 19/4, 2022 at 21:2 Comment(0)
D
0

This may be a late answer but here are some possible reasons:

  • If you are behind a proxy you may need to configure .npmrc if you are using npm or .yarnrc if you are using yarn
  • If proxy is well setup, you may need remove yarn.lock or package-lock.json and re-run npm i or yarn
Dismuke answered 6/5, 2022 at 12:50 Comment(1)
it was useful. I removed .npmrc and it worked😊😊😊Turnout
R
0

I faced the same issue but adding VS Code to the Firewall Exception List has solved my issue.

Rigsdaler answered 1/7, 2022 at 19:17 Comment(0)
S
0

I got the same issue but my case is totally different. I am on Linux, and I get this error because I had a service nginx status off.

Sibyl answered 16/1, 2023 at 8:31 Comment(0)
G
0

Check your nvm is used for the current project path

Gerard answered 25/4, 2023 at 16:47 Comment(1)
Then how to check it?Elizebethelizondo
P
0

turning off VPN solved the issue for me

Also check if you have enough space for installing new packages, I also didnt have enough space...

Putrid answered 15/12, 2023 at 23:7 Comment(0)
P
0

There are many solutions to this issue, none of which worked for me. After giving it some thought I realized I had just updated Docker. As Hail Mary I tried running Docker Desktop in administrator mode and to my surprise that solved the issue.

I'm not too sure why this was all of a sudden a requirement for my machine but if you find yourself clutching at straws give this a shot.

Phosgenite answered 19/3 at 20:38 Comment(0)
M
0

In my case

yarn install --verbose

gave me an error:

Error: connect ETIMEDOUT 2606:4700::6810:1822:443.

To investigate, I first tried to

ping registry.npmjs.org

and received a

Request timed out

response. Then, I tried using

ping -4 registry.npmjs.org

and got a correct response. Based on this, my solution is to turn off IPv6 in the connection properties.

Madalinemadalyn answered 16/4 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.