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

The getaddrinfo EAI_AGAIN error again #15780

Closed
AgentCoop opened this issue Oct 5, 2017 · 14 comments
Closed

The getaddrinfo EAI_AGAIN error again #15780

AgentCoop opened this issue Oct 5, 2017 · 14 comments
Labels
dns Issues and PRs related to the dns subsystem. question Issues that look for answers.

Comments

@AgentCoop
Copy link

  • v6.11.4, within the node:6.11.4-onbuild image:
  • Linux 0123f9db6b51 4.12.8-2-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Fri Aug 18 14:08:02 UTC 2017 x86_64 GNU/Linux:
  • dns.lookup():

There are lots of similar issues but not one stated clearly how this problem can be fixed.

In run bower install --allow-root when building a Docker image and every time I get errors like this one: bower morris.js#^0.5.1 EAI_AGAIN Request to https://registry.bower.io/packages/morrisjs failed: getaddrinfo EAI_AGAIN registry.bower.io:443

The bower package raising error can be any. Some people say that the problem relates the number of libuv threads but tweaking UA_THREADPOOL_SIZE environment variable did not help.

With few packages to install there are no issues, in my case I have about 20 packages to install and the error appears somewhere in the middle of the process.

As for now I have to use this "solution":

RUN bower install --allow-root; exit 0 # Workaround for the bower install getaddrinfo EAI_AGAIN error
RUN bower install --allow-root
@bnoordhuis bnoordhuis added dns Issues and PRs related to the dns subsystem. question Issues that look for answers. labels Oct 5, 2017
@bnoordhuis
Copy link
Member

EAI_AGAIN means the DNS server replied that it cannot currently fulfill the request. (If you want the hairy details, the RCODE field in the response is set to 2, SERVFAIL.)

There is no single solution because it entirely depends on why the DNS server sends that back. Maybe it's overloaded, maybe the network is down, maybe it got the same reply from its upstream server.

In general, the best you can do is wait a while and try again. Hope that helps.

@corvello
Copy link

I found this same situation today. Its really a DNS issue. I workaround setting up the github.com ip address temporary on the hosts file .

@hackhat
Copy link

hackhat commented Aug 13, 2018

Im getting this on docker, not sure why.

@AnirbanKundu
Copy link

I am getting this error while trying to dockerizing my Node JS app

@oskapt
Copy link

oskapt commented Oct 1, 2018

Im getting this on docker, not sure why.

If you're using an image derived from alpine linux, there are known issues with the musl dns resolver.

If working in Kubernetes, the alpine dns issues create additional problems with options ndots:5. A workaround is to use options ndots:2 to force normal 3-part domain names to be tried as fully-qualified.

(Edited: Added K8S detail)

@akerdi
Copy link

akerdi commented Mar 28, 2020

Centos 7 Docker

Fixed by restart docker: systemctl restart docker

@keybraker
Copy link

I am getting this error randomly after a day or so of running, can someone tell me how to avoid the dns server all together?

@poojachakrawarti
Copy link

getaddrinfo EAI_AGAIN https how to solve this issue while using Auth0

@nick-0101
Copy link

nick-0101 commented Apr 25, 2022

I got this error while trying to connect 2 postgres services in my docker compose file. The problem was that the incorrect host was being passed.

Context:

analytics-microservice_db:
    image: postgres
    volumes:
      - analytics-microservice_db:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=analytics_microservice
      - POSTGRES_INITDB_ROOT_PASSWORD=analytics_microservice

In this example, the host name I should be passing to my postgres connection should be analytics-microservice_db, however I was passing postgres and as a result, I was getting the getaddrinfo EAI_AGAIN error. This makes sense too because that error means that the DNS lookup timed out because it couldn't find the hostname postgres

@melroy89
Copy link

melroy89 commented Jul 14, 2022

In this example, the host name I should be passing to my postgres connection should be analytics-microservice_db, however I was passing postgres and as a result, I was getting the getaddrinfo EAI_AGAIN error. This makes sense too because that error means that the DNS lookup timed out because it couldn't find the hostname postgres

In your case, specify a custom network service.

services:
  server:
    networks:
      my-network:
  db-service:
    networks:
      my-network:

networks:
  my-network:

See also: https://docs.docker.com/compose/networking/#specify-custom-networks


But when you try to access the WWW internet and getting getaddrinfo EAI_AGAIN error... I think we should update the docker/containerd systemd service files under Linux. Like adding:

After=network-online.target
Wants=network-online.target

And/OR adding:

After=nss-lookup.target to be sure the DNS is ready.

@gkarabotsos
Copy link

I am getting a similar issue, this time with minikube v1.27.0. There is one pod that can't resolve the hostname, while for others is resolved: getaddrinfo EAI_AGAIN undefined

@lwmxiaobei
Copy link

lwmxiaobei commented Nov 25, 2022

I am getting a similar issue: getaddrinfo EAI_AGAIN buy.itunes.apple.com,normal after retry

@getanwar
Copy link

I am having the same issue repeatedly and every time I have to restart docker using service docker restart command. Is there any solution to this?

FoxxMD added a commit to FoxxMD/multi-scrobbler that referenced this issue Jul 24, 2023
DNS issues could be result of musl's lack of dns over tcp for large/frequent queries

https://bell-sw.com/blog/how-to-deal-with-alpine-dns-issues/
nodejs/node#15780 (comment)

alpine 3.18 includes support for dns over tcp in musl
FoxxMD added a commit to FoxxMD/multi-scrobbler that referenced this issue Sep 13, 2023
* Updates alpine 3.17 -> 3.18
  * Main reason is to potentially fix DNS issues related to musl #88
    * nodejs/node#15780 (comment) and https://bell-sw.com/blog/how-to-deal-with-alpine-dns-issues/
    * Resolved in musl 1.2.4
      * https://gitlab.alpinelinux.org/alpine/tsc/-/issues/43
      * https://www.openwall.com/lists/musl/2023/05/02/1
  * Bumps npm 9.1.2 -> 9.6.6

New/changed ENVs used by LSIO may require removing "stored" ENVs if using portainer
nicolasbriere1 added a commit to ZeroGachis/.github that referenced this issue Jan 29, 2024
Following this node issue nodejs/node#15780
We tried to upgrade vault action to nodejs20 to avoid it
@recall704
Copy link

I‘m getting this on docker with docker-compose

version: '3.8'
 
services:
  lobe-chat:
    image: lobehub/lobe-chat
    container_name: lobe-chat
    restart: always
    ports:
      - '3210:3210'
    environment:
      OPENAI_API_KEY: sk-xxxx
      OPENAI_PROXY_URL: https://api-proxy.com/v1
      ACCESS_CODE: lobe66

Here's how I solved it, I created the etc/resolv.conf file in my local directory and mounted it into the container via volumes

version: '3.8'
 
services:
  lobe-chat:
    image: lobehub/lobe-chat
    container_name: lobe-chat
    restart: always
    volumes:
      - "./etc/resolv.conf:/etc/resolv.conf"
    ports:
      - '3210:3210'
    environment:
      OPENAI_API_KEY: sk-xxxx
      OPENAI_PROXY_URL: https://api-proxy.com/v1
      ACCESS_CODE: lobe66

You can customize the content of the file

cat etc/resolv.conf 
nameserver 192.168.82.1
nameserver 1.1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dns Issues and PRs related to the dns subsystem. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

16 participants