yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.42k stars 2.72k forks source link

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

Closed MichelDiz closed 3 years ago

MichelDiz commented 6 years ago

Do you want to request a feature or report a bug? maybe

What is the current behavior? PS. I tried to solve this by searching here and by Google, but not one approach solved it. I also uninstalled, cleaned up caches, rebooted mac. Clean DNS, Flush everything I could. I did everything I know.

After install zsh keeps saying "There appears to be trouble with your network connection. Retrying..."

error An unexpected error occurred: "https://registry.yarnpkg.com/get-caller-file: read ETIMEDOUT".
info If you think this is a bug, please open a bug report with the information provided in "/Users/micheldiz/umover-fire/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
info There appears to be trouble with your network connection. Retrying...

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

Please mention your node.js, yarn and operating system version. yarn -v 1.3.2 node -v v9.3.0

Mac Os High Sierra.

Details:

Arguments: 
  /usr/local/bin/node /usr/local/Cellar/yarn/1.3.2/libexec/bin/yarn.js add react-apollo

PATH: 
  /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/bin/:/Users/micheldiz/Library/Android/sdk/tools:/Users/micheldiz/Library/Android/sdk/platform-tools:/usr/local/bin/:/Users/micheldiz/Library/Android/sdk/tools:/Users/micheldiz/Library/Android/sdk/platform-tools

Yarn version: 
  1.3.2

Node version: 
  9.3.0

Platform: 
  darwin x64

npm manifest: 
  {
    "main": "node_modules/expo/AppEntry.js",
    "private": true,
    "dependencies": {
      "expo": "^25.0.0",
      "react": "16.2.0",
      "react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz"
    }
  }

yarn manifest: 
  No manifest

Lockfile: 
  No lockfile

Trace: 
  Error: read ETIMEDOUT
      at _errnoException (util.js:999:13)
      at TLSWrap.onread (net.js:629:25)
alienfractal commented 5 years ago

Upgrading my nodejs to the latest version worked for me. Hi @saeedahmadee
Has this fix worked for you so far?

wageeshwara commented 5 years ago

@MichelDiz I tried yarn --network-timeout 100000 install, and it worked. Full Dockerfile can be found at https://github.com/vietnam-devs/coolstore-microservices/blob/master/src/web/Dockerfile

This worked for me

Node version 8.1 Yarn version 1.12.3

TTy32 commented 5 years ago
  • Delete all "locks" and rm node_modules. rm -rf node_modules/

This worked for me in addition to removing yarn.lock

Thanks!

polonel commented 5 years ago

I'm getting this only inside a Docker container and only within arm32v6 builds. Tried all the suggestions/solutions and nothing has worked for me.

EDIT: For me, I was able to identify the issue with a slow performing qemu version. Updated qemu and all worked well.

stuck1233333 commented 5 years ago

Same. WTF

sharifzadesina commented 5 years ago

Same, only inside Docker.

redtxai commented 5 years ago

I trying some "voodoos":

  • Delete all "locks" and rm node_modules. rm -rf node_modules/
  • Clean a flush all connections things like DNS, caches and so on.
  • Terminal commands:
  • [ ] set http_proxy=
  • [ ] set https_proxy=
  • [ ] yarn config delete proxy
  • [ ] npm config rm https-proxy
  • [ ] npm config rm proxy
  • [ ] npm config set registry "http://registry.npmjs.org" or npm config set registry "https://registry.npmjs.org"
  • Restart your terminal and Try.
  • Use : yarn add mypckge --network-timeout 100000 or yarn --network-timeout 100000 but first try just yarn
  • Restart your terminal and Try yarn again and/or with --network-timeout.

For me is working for now. I'll see how will be over time.

it worked for me!

I was with problem when tried "yarn" and also "npm install", it was stuck in fetching package and loadalldepsintoidealtree.

craigpalermo commented 5 years ago

Resolved for me by simply deleting package-lock.json. Thanks, @MichelDiz.

pthorsley commented 5 years ago

At home it works fine, but at work on vpn total garbage, constant timeouts. So tried this: yarn --network-timeout 100000 and it still failed a few times, BUT SUCCESS after forever, finally got past step [2/4]....YEAHHHHHHHHH!!!!!!!!!

npx: installed 63 in 30.591s

Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts...

yarn add v1.13.0 [1/4] Resolving packages... [2/4] Fetching packages... info There appears to be trouble with your network connection. Retrying... info There appears to be trouble with your network connection. Retrying... info There appears to be trouble with your network connection. Retrying... info There appears to be trouble with your network connection. Retrying... info fsevents@1.2.7: The platform "win32" is incompatible with this module. info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.4: The platform "win32" is incompatible with this module. info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning "react-scripts > pnp-webpack-plugin > ts-pnp@1.0.0" has unmet peer dependency "typescript@*". [##########--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 1111/23233

sumit6b commented 5 years ago

None of the solutions were working for me. So I tried restarting my computer and it worked 🤦‍♂️

Prateekjaiiho commented 5 years ago

in my case i removed the package.json.lock file in my root folder and where i want to create a new react app worked!!

adabru commented 5 years ago

If you have ip6-only network and the error occurs, you can try to workaround with adding

2606:4700::6810:1723 registry.yarnpkg.com
2606:4700::6810:1723 registry.npmjs.org
2606:4700::6810:ab63 yarnpkg.com

to /etc/hosts. You can get the ip6 with nslookup registry.yarnpkg.com. https://github.com/yarnpkg/yarn/issues/6031

abjrcode commented 5 years ago

The problem remains, Windows Server 2019 Datacenter running in AWS I doubt the AWS network is having issues as this happened over multiple days. It is either something fishy with your binary, the registry or some Windows service doing something fishy with the traffic and most likely one of the earlier two.

The underlying problem in our case turned out to be nodejs 10.15.0 and upgrading to later node (10.16.3) version resolved the issue.

brulio93 commented 4 years ago

Hi guys!

I was facing same issue with .local address on Ubuntu and I fixed with this:

sudo gedit /etc/nsswitch.conf

then I change this lines on that file:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

to

hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

dimarray commented 4 years ago

If the yarn.lock was generated while yarn was pointed at an alternate registry (via an .npmrc file, npm config, or --registry), then it will try to resolve the package from the same source. Before you delete your yarn.lock, you can check if that is what is causing your problem with something like: cat yarn.lock |grep resolved| grep -v 'registry.yarnpkg.com'

trust2065 commented 4 years ago

You may want to try uninstall and reinstall it.

I actually tried a lot of stuffs...

npm version: 6.12.1 node version: 12.13.1 windows 10 x64 trying to install expo-cli 3.9.1

  1. update npm/yarn to latest
  2. update node to latest
  3. clear npm registry
  4. clear npm/yarn cache
  5. delete node_modules and yarn.lock
  6. restart my laptop/cmd/cmder
  7. npm uninstall expo-cli then reinstall it

It works after 7th step.

0xADD1E commented 4 years ago

Original analysis by @Hinaser

Everytime the message There appears to be trouble with your network connection. Retrying... is output on console, there is a RST packet sent from my PC to npm server. You know, RST packet is to forcibly close TCP connection. But it is sent from client PC. I feel strange about this.

Next, I wondered what causes RST packet sent from my PC. I found that every time before RST packet is sent, there are packets indicating TCP ZeroWindow, meaning data receiving entity (in this case it is my client PC) tells to a sender to stop sending packet until the receiver allow to do it.

After sender receives packets indicating TCP ZeroWindow, client must send TCP Window Update to server in order to resume TCP communication.

But I couldn't find those TCP Window Update packet sent from my client PC. The npm server kept waiting to be allowed to send data but my client PC didn't tell to do so. Then it is timed out and RST packet was sent from my PC.

Apparently, the root cause is not to send TCP Window Update packet to resume communication from client. As I haven't had problem downloading large files from internet, I suspect the issue is in network code in node binary compiled for Windows.

After separately running into this issue, and doing my own packet analysis, this reflects what I’m seeing. The other thing that seems strange is, applications like cURL have no issue with this, and are able to keep up with the server. Is there any way to have yarn buffer the file to reduce the amount of work it needs to do? This issue is also present with npm, so I’m really not sure what to do here

LunaticMuch commented 4 years ago

I've found my yarn keeps trying to connect to verbose 0.349 Performing "GET" request to "https://yarnpkg.com/latest-version".

The host is unreachable as I am using a proxy and I have a local registry. Any way to disable this check?

RusinovAnton commented 4 years ago

None of the solutions were working for me. So I tried restarting my computer and it worked

I also updated my Docker for Mac program and then restarted the system, after that the problem is gone so far.

CodHeK commented 4 years ago

Do you want to request a feature or report a bug? maybe

What is the current behavior? PS. I tried to solve this by searching here and by Google, but not one approach solved it. I also uninstalled, cleaned up caches, rebooted mac. Clean DNS, Flush everything I could. I did everything I know.

After install zsh keeps saying "There appears to be trouble with your network connection. Retrying..."

error An unexpected error occurred: "https://registry.yarnpkg.com/get-caller-file: read ETIMEDOUT".
info If you think this is a bug, please open a bug report with the information provided in "/Users/micheldiz/umover-fire/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
info There appears to be trouble with your network connection. Retrying...

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

Please mention your node.js, yarn and operating system version. yarn -v 1.3.2 node -v v9.3.0

Mac Os High Sierra.

Details:

Arguments: 
  /usr/local/bin/node /usr/local/Cellar/yarn/1.3.2/libexec/bin/yarn.js add react-apollo

PATH: 
  /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/bin/:/Users/micheldiz/Library/Android/sdk/tools:/Users/micheldiz/Library/Android/sdk/platform-tools:/usr/local/bin/:/Users/micheldiz/Library/Android/sdk/tools:/Users/micheldiz/Library/Android/sdk/platform-tools

Yarn version: 
  1.3.2

Node version: 
  9.3.0

Platform: 
  darwin x64

npm manifest: 
  {
    "main": "node_modules/expo/AppEntry.js",
    "private": true,
    "dependencies": {
      "expo": "^25.0.0",
      "react": "16.2.0",
      "react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz"
    }
  }

yarn manifest: 
  No manifest

Lockfile: 
  No lockfile

Trace: 
  Error: read ETIMEDOUT
      at _errnoException (util.js:999:13)
      at TLSWrap.onread (net.js:629:25)

Might be a little late but, this method of debugging worked for me!

first check your yarn's configs list -> $ yarn config list

Then check for proxy's that might be set. usually https-proxy or proxy

Ex:

gaganganapathyas:Transcriptor codhek$ yarn config list
yarn config v1.21.1
info yarn config
{
  'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-commit-hooks': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '^',
  'bin-links': true,
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'https://registry.yarnpkg.com',
  'strict-ssl': true,
  'user-agent': 'yarn/1.21.1 npm/? node/v13.6.0 darwin x64',
  'https-proxy': 'http://172.31.2.4:8080',   [ THIS ONE HERE HAD TO BE DELETED ]
  lastUpdateCheck: 1549658796393
}
info npm config
{
  '//registry.npmjs.org/:_authToken': 'd976d660-cf65-4d3e-9e3c-e05c2beef418',
  python: '/usr/bin/python'
}
✨  Done in 0.07s.

So just delete using $ yarn config delete https-proxy

ghost commented 4 years ago

I trying some "voodoos":

  • Delete any "*.lock" and rm node_modules. Or rm -rf node_modules/
  • Clean a flush all connections things like DNS, caches and so on.
  • Terminal commands:
  • [ ] set http_proxy=
  • [ ] set https_proxy=
  • [ ] yarn config delete proxy
  • [ ] npm config rm https-proxy
  • [ ] npm config rm proxy
  • [ ] npm config set registry "http://registry.npmjs.org" or npm config set registry "https://registry.npmjs.org"
  • Restart your terminal and Try.
  • Use : yarn add mypckge --network-timeout 100000 or yarn --network-timeout 100000 but first try just yarn
  • Restart your terminal and Try yarn again and/or with --network-timeout.

For me is working for now. I'll see how will be over time.

Thanks!

revelt commented 4 years ago

In my case, I downloaded react via yarn once at work, it has its own corporate npm registry. Yarn apparently set the "source" for react to corporate npm registry. Now, at home, I can't/don't want to connect to corporate VPN, I come to a clean folder, try to create-react-app, npx create-react-app zzz and instead of going to real npm, yarn is looking for react in yesterday's corporate npm registry. Naturally it doesn't work.

Suggestion to yarn maintainers:

If yarn fails, error with message "There appears to be trouble with your network connection", add an additional check, maybe official npm registry is not being queried, and if so, try official npm registry instead.

This is very important. It's not internet down, it's wrong registry.

Personally, I think that's one of the examples how competition between yarn and npm makes users suffer, maybe there should be only one package manager...

sareljacksmit commented 4 years ago

I do believe that my issue was different than any of the ones discussed here so I am going to comment. Doing a yarn install gave me the dreaded "There appears to be trouble with your network connection" issue and the "voodoo" above did nothing for me. A co-worker helped(thanks Steve) and doing a printenv | grep proxy showed that I had values set to 127.0.0.1:8888 but I do not know where it magically came from. I just did unset http_proxy and unset https_proxy Success!!

popbee commented 4 years ago

I have a feeling that it's not the network at all. It's a function on the number of files and/or the size. The packages I ran always into this issue has a lot of files (material-ui icons). I suspect the tgz processing (either packing on the server or unpacking on the client) is the culprit but it is reported as a "networking" issue when it is not.

icons-3.0.1.tgz ~684kb -> representing ~16MB for 10k files

Also the following was reported: nyc-11.7.3.tar ~3.4M representing ~18 MB for 4.7K files

ali-master commented 4 years ago

What should we do when we are using Lerna and yarn as its installer?

GiovanniGiampaolo commented 4 years ago

I trying some "voodoos":

  • Delete any "*.lock" and rm node_modules. Or rm -rf node_modules/
  • Clean a flush all connections things like DNS, caches and so on.
  • Terminal commands:
  • [ ] set http_proxy=
  • [ ] set https_proxy=
  • [ ] yarn config delete proxy
  • [ ] npm config rm https-proxy
  • [ ] npm config rm proxy
  • [ ] npm config set registry "http://registry.npmjs.org" or npm config set registry "https://registry.npmjs.org"
  • Restart your terminal and Try.
  • Use : yarn add mypckge --network-timeout 100000 or yarn --network-timeout 100000 but first try just yarn
  • Restart your terminal and Try yarn again and/or with --network-timeout.

For me is working for now. I'll see how will be over time.

After two hours of finding solution, come your answer thanks!

elizad commented 4 years ago

same issues on win10 with yarn . The "voodoos" work partially , able to run only yarn . yarn boostrap or yarn clean && yarn bootstrap don t work :(

CobraCoral commented 4 years ago

I was struggling with this since June this year. I finally got it to work... Here is what I did:

  1. This will show you your current config yarn config list

  2. I then set my registry to use the "HTTP" (NOTE: NOT the HTTPS!!!) yarn config set registry "http://registry.npmjs.org"

  3. For good measure, I did the same for npm: npm config set registry "http://registry.npmjs.org"

  4. I changed my .vimrc to do as follows: Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile --network-timeout 1000000'}

  5. You you can also cd to: ${HOME}/.local/share/nvim/plugins/coc.nvim (if you are on VIM, then go to ~/.vim and search for coc.nvim to see where it is installed with "cd ~/.vim && find . -name coc.nvim -type d"). Then run: yarn install --frozen-lockfile --network-timeout 1000000

This finally worked for me.... And I kinda know what the issue is. I noticed that my machine sends a RST same issue some people have raised here, which just makes it not work. By switching to HTTP somehow I am bypassing whatever issues are there on this machine/network.

ivolucien commented 4 years ago

Just posting this here in case others have the same problem.

The two things that I've seen that fix this (for 2 different computers) are:

sergey-shpak commented 3 years ago

after about 2 hours and trying all the solutions, finally this worked for me: npm config set registry "http://registry.npmjs.org" and then: yarn config set registry "http://registry.npmjs.org"

xccjk commented 3 years ago

The same problem exists on my machine. OS: macOS 10.14.6 Node: 14.15.0 NPM: 6.14.8 Yarn: 1.22.10

In some networks, the initialization project is very slow, and the network reason is always prompted, but the installation is successful, and it took about 10 minutes

After turning on the circumvention network, it is still as smooth as before

Do you know the reason?

Hazmi35 commented 3 years ago

I have the same problem, but only when I'm building multi-platform Docker images with buildx, when I first received this problem, I think it's only a network issue from my home network, but it's actually not, it's also affecting my docker/build-push-action in https://github.com/Hazmi35/jukebox too, strangely it's not affecting the AMD64 platform as you can see in https://github.com/Hazmi35/jukebox/runs/1430274704?check_suite_focus=false, AMD64 only takes 74.1 seconds, which itself is quite slow, but ARM platforms (ARM64, ARMv7, and ARMv6) can take up to 1136.06 seconds. Any tips? I've using network-timeout 600000 to prevent the build from failing. But now it's very slow

merceyz commented 3 years ago

Closing as fixed in v2 where the timeout logic is less susceptible to this sort of issue

https://yarnpkg.com/getting-started/migration

aprilmintacpineda commented 3 years ago

I'm having the same problem when running yarn add or yarn global add on Github actions. It's intermittent. Sometimes it recovers, sometimes it fails.

sibelius commented 3 years ago

@Hazmi35 did you figure it out how to improve yarn install times when building ARM?

sibelius commented 3 years ago

related issue https://github.com/nodejs/docker-node/issues/1335

Hazmi35 commented 3 years ago

@Hazmi35 did you figure it out how to improve yarn install times when building ARM?

@sibelius Sadly no, I moved to npm when I tried Yarn 2 on that project and it seems to be incompatible. Although, before that, I don't see any issues about the slow download other than the compile-time for native modules is slow in emulated build, and it's also happening with npm.

ivolucien commented 2 years ago

Yet another way this issue can occur, if you have a split dns setup with a vpn, the default dns server needs to resolve the npm registry. For my setup this worked:

sudo resolvectl default-route [your-vpn-device-name] true && sudo resolvectl default-route [your-internet-device-name] false

sunny-to commented 2 years ago

I was running into this in a Docker container. I think it was actually a disk space issue and not a networking issue, as deleting all my unused Docker images fixed the issue for me.

ranjithrd commented 2 years ago

If someone is still facing this issue with scoped packages (@types/react for example), please refer to #8797 It can be fixed by using node version v17.7.1

odahcam commented 2 years ago

After trying everything I could, today the problem just stopped happening. 😵‍💫

natesdot commented 1 year ago

I have been troubleshooting this issue myself for several hours now, and my situation is different from all others that I have seen but the same error persists. Wondering if anyone could shed some light on the situation.

I get this error only running inside of docker, if I run the same commands on the host it works fine(100% of the time). The connections are very fast, installing packages takes just a few seconds in both cases. So there is no timeout situation(but have tried messing with that option). Running wget/curl against the "failed" urls results in success 100% of the time.

However yarn continues to report sporadic "trouble" when running inside of docker. I made a small breakthrough a short time ago, found that running docker with --network host allows the commands to run without errors. So I am assuming it has something to do with the docker iptables rules in my case? I'm no iptables expert or even at this point I wouldn't even consider myself a novice it's probably been 10+ years since I last touched iptables. The problem happens on all hosts, using the default docker setup/rules. So I can't imagine it would be related to iptables, but what else could it be if --network host resolves the issue for me? I don't know..

natesdot commented 1 year ago

I have been troubleshooting this issue myself for several hours now, and my situation is different from all others that I have seen but the same error persists. Wondering if anyone could shed some light on the situation.

Mostly pure luck I suppose, but I managed to fix my issue by setting these sysctl flags

I never thought I'd need to adjust a kernel setting like this for an otherwise completely idle system running just one container and this yarn program accessing a few urls. Can't say I've touched these parameters much at all in my 26ish years of using Linux.

Juanc1to commented 1 year ago

After poking at many of the proxy, cache, and timeout settings that others have suggested, I also rebooted my router and that immediately fixed the problem. It is certainly curious to me that the router can get into a state where these yarn network requests time out, but all other "normal" internet traffic functions properly. I would be very interested in learning more about what might cause the router to get into such a state!

IshanKute commented 1 year ago

I am also experiencing this. Internet pulling down 70Mbps,

Timeout increase did not resolve, tried nuking docker containers, removing package.lock etc.

However, I got around this by tethering my phones LTE. wtf?

Thank you so much. Weird but this is the only thing that worked for me.

Rafael3326 commented 1 year ago

After poking at many of the proxy, cache, and timeout settings that others have suggested, I also rebooted my router and that immediately fixed the problem. It is certainly curious to me that the router can get into a state where these yarn network requests time out, but all other "normal" internet traffic functions properly. I would be very interested in learning more about what might cause the router to get into such a state!

isso resolveu meu problema, eu te amo seu gringo lindooo <3 <3

jahammo2 commented 1 year ago

For anyone still running into this issue, the fix for me was to connect to a different WiFi connection.

None of the other tricks (adding --timeout, yarn cache clean, npm config rm proxy, etc) worked but changing my WiFi connection did 🤷‍♂️ .

CalebFenton commented 1 year ago

My problem was that my docker daemon didn't have ipv6 tables enabled. I had ipv6 enabled but not the tables. https://docs.docker.com/config/daemon/ipv6/

I diagnosed this by running the docker container's /bin/ash and checking network stuff. I could ping my router, ping my DNS, and resolve domains to IPs, but I couldn't ping google because that went to an ipv6 address. After fixing the daemon config and restarting the service, everything worked fine.

callmebar commented 7 months ago

In my case, I've gotten ETIMEDOUT immediately after yarn install no matter how huge was --network-timeout. I was monitoring packets through WireShark and noticed that in TCP handshake my side sends RST after getting SYN,ACK from yarnpkg server. Digging deeper, I found the reason.

node:net has a parameter autoSelectFamilyAttemptTimeoutDefault be default it is 250ms, that is not enough for my slow internet connection. This parameter at the current version if node (v21.7.1) can not be changed by NODE_OPTIONS, only from code, so all the libraries that use node.net must adjust this parameter, but they do not.

So it is not really yarn problem, but it can be fixed on the yarn level by, for example, running net.setDefaultAutoSelectFamilyAttemptTimeout(networkTimeout) in utils/request_manager:setOptions.

However, since I can't fix all libraries that ignore this parameter, I manually patched this line in node and built it from source.