Error: getaddrinfo ENOTFOUND ${IP}

narc2ss·2022년 11월 4일

상황

외부 서버에서 제공하는 API를 호출하였더니 다음과 같은 에러 발생

(node:55604) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND ${IP}
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:26)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:55604) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:55604) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

서버 호스트 정보의 변경사항 없음.

네트워크 접속상태 확인

이상 없음.

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=104 time=40.856 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=104 time=39.215 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=104 time=40.607 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=104 time=40.370 ms
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 39.215/40.262/40.856/0.628 ms

Google에 ping 요청

$ ping google.co.kr
ping: unknown host google.co.kr 

뭔지는 모르겠으나.. 이상함을 감지

재부팅 후 API 호출

노트북 재부팅 후 외부 서버에서 제공하는 API를 호출하였더니 정상 동작됨.

8.8.4.4

추후 같은 문제 발생시 해볼 솔루션

# /etc/resolve.conf

# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
nameserver 172.31.0.2
nameserver 10.8.0.1
nameserver 1.1.1.1
nameserver 8.8.4.4 # 추가

8.8.4.4은 Google LLC의 무료 공개 DNS서버의 IP주소라고 한다.
또한 위에서 네트워크 상태 확인시 입력했던 8.8.8.8도 마찬가지였다.

결론

재부팅 짱

참고

profile
시장은 빠르게 변화한다, 변화에 유려한 코드 짜기

0개의 댓글