always fail with slow internet, while npm does work

Hi folks, I ran out of my bandwidth and Internet speed reduces around 50KBps, yarn fails to install its components, while npm does work finally a little slower but it work.

Trace: 
   Error: getaddrinfo EAI_AGAIN registry.yarnpkg.com:443
     at Object.exports._errnoException (util.js:1026:11)
     at errnoException (dns.js:33:15)
     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

Let me know if any further input needed.

Author: Fantashit

11 thoughts on “always fail with slow internet, while npm does work

  1. I also experience the same issue, this is a screenshot of a recent occurrance:

    image

    It seems to be somewhat intermittent (almost 60%% probability of happening).

    This is my docker file:

    WORKDIR /opt/app
    
    RUN mkdir -p /opt
    ADD yarn-v0.18.1.tar.gz /opt/
    RUN mv /opt/dist /opt/yarn
    ENV PATH "$PATH:/opt/yarn/bin"
    
    ADD package.json yarn.lock /tmp/
    RUN cd /tmp && yarn
    RUN mkdir -p /opt/app && cd /opt/app && ln -s /tmp/node_modules
    ADD . /opt/app
    RUN cd /opt/app && yarn run gulp
    RUN cd /opt/app && yarn run start
  2. I experienced it too, but setting the network-concurrency parameter to 1 solved it in my case:

    yarn install --network-concurrency 1
    
  3. I had this same issue running yarn in a docker container on Ubuntu 17.04, and found that, in my case, running dnsmasq as a service (for an unrelated project) was causing the containerized yarn install to throw this error. Stopping dnsmasq solved the issue.

  4. I had this issue when doing a yarn install into the Docker base image alexsuch/angular-cli (1.2.1). I figured out that deleting local Docker image and restarting Docker solved the problem.

    I suspect yarn keep failing because of the DNS record not found from the Docker image, for some reason (long Docker exec on my dev laptop can lead to little unwanted behaviours like these).

  5. This problem happen when you change your network, maybe from a wifi network to another one.
    All you need to do is restart the docker service:
    sudo systemctl restart docker

  6. --network-concurrency 1 didn’t work for me, here’s the workaround inspired by @avsd:

    apt-get install -y bind9-host
    registryYarnpkgComIpAddress=$(host registry.yarnpkg.com | awk '/has address/ { print $4 }' | head -n1)
    echo "${registryYarnpkgComIpAddress} registry.yarnpkg.com" >> /etc/hosts
    

Comments are closed.