Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install error - getaddrinfo EAI_AGAIN registry.npmjs.org:443 #270

Closed
akelle17 opened this issue Jan 24, 2018 · 35 comments
Closed

npm install error - getaddrinfo EAI_AGAIN registry.npmjs.org:443 #270

akelle17 opened this issue Jan 24, 2018 · 35 comments

Comments

@akelle17
Copy link

Everytime I try to npm install a file I get the following error:
getaddrinfo EAI_AGAIN registry.npmjs.org:443

I am using stefanscherer/node-windows:8.9.3 image but have had this issue with many other images as well.

Initial npm error:
npm-error

npm logs:
npm-error-2

@StefanScherer
Copy link
Owner

Hi @akelle17
Sounds like a general network problem inside Windows containers.
What's your environment? Windows 10 with Docker for Windows? Or a Windows Server 2016? Which versions, both OS and Docker or D4W?

Maybe running the script mentioned in https://docs.microsoft.com/en-us/virtualization/windowscontainers/troubleshooting gives you more details.

@StefanScherer
Copy link
Owner

Still having problems?

@binarymist
Copy link

This known issue for Docker and is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

@suryaveera1995
Copy link

This issue again coming, can you guys please tell me how to solve this, especially if this is on the AWS

@Rama001
Copy link

Rama001 commented Feb 4, 2019

I can't install browser sync still this error appears.

@alifgithub
Copy link

pm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EAI_AGAIN: request to https://registry.npmjs.org/npm failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443
npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js

any have idea for solve it ? help me please

@StefanScherer
Copy link
Owner

In earlier Windows versions sometimes a sleep has helped before running commands that need internet connection. It seemed that the RUN instruction and setting up network runs in parallel.

See

RUN powershell -Command Sleep 2 ; wget -Uri https://github.com/StefanScherer/win-getaddrinfo/releases/download/1.0.8/getaddrinfo.exe -OutFile C:\Windows\system32\getaddrinfo.exe -UseBasicParsing
as an example

@luckyyang
Copy link

/etc/docker/daemon.json do not work for me. I have to reboot my ubuntu server to resolve my problem.

@raghureddycloud
Copy link

Restarting system resolved my issue.

@karanvij-ai
Copy link

Hi All,

I am running Docker Toolbox on windows 10 home.

Following were the steps(In Docker console -> Docker Quick Start and using bash from git installation):

  1. npm install -g create-react-app
  2. create-react-app frontend
  3. cd frontend
  4. npm run test
  5. npm run build
    6.npm run start
  6. code .

Created docker file(Dockerfile.dev):

FROM node:alpine

WORKDIR '/app'

COPY package.json .

RUN npm install

COPY . .

CMD ["npm", "run", "start"]

$ docker build -f Dockerfile.dev .

Output in console:

Sending build context to Docker daemon 146.5MB
Step 1/6 : FROM node:alpine
---> ef7d474eab14
Step 2/6 : WORKDIR '/app'
---> Using cache
---> c47b0eb2c3c1
Step 3/6 : COPY package.json .
---> Using cache
---> e5c66b740c8b
Step 4/6 : RUN npm install
---> Running in 962746bea142
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/react failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-09-21T01_00_35_350Z-debug.log
The command '/bin/sh -c npm install' returned a non-zero code: 1

Also, I couldn't find the complete log, not sure where is location.

Please help, Thanks

@nirajkvinit
Copy link

This known issue for Docker and is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

Yes! It worked! Thank you!

@sid42
Copy link

sid42 commented Dec 26, 2019

@karanvij-ai Seeing the same issue, were you able to find a fix?

@Tokenyet
Copy link

Tokenyet commented Jan 9, 2020

I got a server network issue, and a client restart to let me ssh, and the problem happened. I'll show my steps to slove this issue, hope it help someone 😄

  1. Follow the dns modification step above.
  2. sudo service docker restart or sudo systemctl restart docker to restart docker.
  3. sloved (maybe).

@gitaumoses4
Copy link

@Tokenyet it did solve my issue. Thanks alot.

@edvegas
Copy link

edvegas commented Feb 26, 2020

I couldn't resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.:
docker build . --network host -t mytag ...

@cyansprite
Copy link

Not sure if this will help or even why this is a thing but..
To fix this issue I created the /etc/docker/daemon.json file, sudo systemctl restart docker, then delete the file, sudo systemctl restart docker again.. THEN it works, just restarting docker didn't work, nor did it work when the file was present. Weird but.. this is here if it helps anyone.

@hmoralesp
Copy link

I couldn't resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.:
docker build . --network host -t mytag ...

it's works

@anuragarwalkar
Copy link

I couldn't resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.:
docker build . --network host -t mytag ...

worked for me 😊

@Xuezenghuigithub
Copy link

I couldn't resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.:
docker build . --network host -t mytag ...

it's works. thank u so much~👏

@mojtaba-eshghie
Copy link

This known issue for Docker and is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

Worked for me.

@DaniVS
Copy link

DaniVS commented Oct 11, 2020

I couldn't resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.:
docker build . --network host -t mytag ...

This solved my issue on Fedora 32.

@Kif11
Copy link

Kif11 commented Nov 27, 2020

I had the same issue on WSL2 Ubuntu, @binarymist solution worked.

@mojtabaRKS
Copy link

@binarymist @Tokenyet thank you guys ! your solution was really helpful !

@CimeM
Copy link

CimeM commented Feb 4, 2021

Problem
I am using Docker for Desktop (20.10.2) on Windows 10 (20H2 OSS build 19042). I could not install NPM packages due to:
npm ERR! request to https://registry.npmjs.org/canvas failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
Pinging the registry.npmjs.org returned that the address could not be resolved so I turned to DNS.

Solution
Being inside a windows container I checked what interface number the container was using with:
Get-DnsClient
Then I changed to a known DNS address with: (The interface number was 4 with my container)
Set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses ("8.8.8.8")

I hope this is helpful to those using windows containers on Windows clients.

@afonsoalbrecht
Copy link

afonsoalbrecht commented Jun 12, 2021

This known issue for Docker and is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

that doesn't work for me and the other solutions don't work either. I'm on Ubuntu 20.04

@NickKelly1
Copy link

restarting worked for me (sudo systemctl restart docker)

@preetsindhal
Copy link

This known issue for Docker and is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

After creating the file I had to reboot the machine then it worked. 👍

@Iman
Copy link

Iman commented Oct 4, 2021

This known issue for Docker and is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

Works like a charm on a Digitalocean VPS

@chibuikesebastine
Copy link

I couldn't resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.: docker build . --network host -t mytag ...

You just saved me severally days of headache.

@mr-zero-03
Copy link

I couldn't resolve issue with adding DNS setting to docker daemon, but I found another solution (maybe this will be useful for someone) - just use host network to resolve dns names by adding --network host setting, ex.: docker build . --network host -t mytag ...

This one worked for me! Thank you

@ShinJustinHolly3317
Copy link

This known issue for Docker and is discussed in detail here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

Simple fix is to create the file /etc/docker/daemon.json

and insert:

{
    "dns": ["10.0.0.2", "8.8.8.8"]
}

where 10.0.0.2 is the first DNS server your machine requests records from, and 8.8.8.8 is the fallback DNS server, google in this case.

This works for me. Thanks a lot dude.

@ThangalakshmiKP
Copy link

ThangalakshmiKP commented Sep 13, 2022

This issue again coming, can you guys please tell me how to solve this, especially if this is on the AWS

yes i am also getting same like:
{
"status": "failure",
"err_msg": "getaddrinfo EAI_AGAIN bucket_name.s3.amazonaws.com bucket_name.s3.amazonaws.com:443",
"status_code": 404
}
please help!

@mustafaStakater
Copy link

For the peeps using Buildah who came across this issue when using alpine image, I updated the buildah build command to override container dns with google dns server buildah bud --dns='8.8.8.8'

@stasfainberg
Copy link

stasfainberg commented Dec 13, 2023

hey guys,

i run Docker 24.0.7 on Ubuntu 22.04.3 LTS.
i tried installing express module on a Node.js container (docker run -v $PWD:/app -w /app node npm install express) but it failed with the same errors.

weird but... a restart solved my problem too!!!

could be related to any port mapping i run before that with Nginx container (docker run -p 8080:80 -v $PWD:/usr/share/nginx/html nginx) i saw it created a FW rule on my Ubuntu

docker-node-error-01

@baba216
Copy link

baba216 commented Dec 20, 2023

Hello Members,

Docker Version: 24.0.7
OS:Ubuntu 22.04.3 LTS

Short answer:
even after adding dns in daemon.json its not working, enable IPv4 forwarding [ref]

Long Answer :
Even after after adding dns in daemon.json the issue was not resolved. On further investigation and downgrading to docker version 20.10.17 , I noticed one additional error message [ie, IPv4 forwarding is disabled. Networking will not work.] which was not visible for docker version 24.0.7. Please find complete details

Step 4/6 : RUN npm install
---> [Warning] IPv4 forwarding is disabled. Networking will not work.
---> Running in 410fdfb3445e
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/axios failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

npm ERR! A complete log of this run can be found in:

npm ERR! /root/.npm/_logs/2023-12-20T09_56_37_800Z-debug.log

The command '/bin/sh -c npm install' returned a non-zero code: 1

After I enabled ipv4 forward. It started working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests