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

http request getaddrinfo ENOTFOUND #7931

Closed
zyy7259 opened this issue Aug 1, 2016 · 4 comments
Closed

http request getaddrinfo ENOTFOUND #7931

zyy7259 opened this issue Aug 1, 2016 · 4 comments
Labels
http Issues or PRs related to the http subsystem.

Comments

@zyy7259
Copy link

zyy7259 commented Aug 1, 2016

  • Version: v6.3.1
  • Platform: Darwin MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
  • Subsystem: http.request
  • OS: OS X EI Capitan 10.11.6 (15G31)

I'm doing a batch task, uploading a lot of files to a file server. I try several times. There will be some of the requests failed almost every time. Here is the Error:

{ Error: getaddrinfo ENOTFOUND nos.netease.com nos.netease.com:80
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'nos.netease.com',
  host: 'nos.netease.com',
  port: 80,
  options:
   { host: 'nos.netease.com',
     port: 80,
     path: '/yx-web/official%2F1.1.8%2Fres%2Fimage%2Fbase%2F3rd%2Fm-logo44.png',
     method: 'PUT',
     headers:
      { Date: 'Mon, 01 Aug 2016 02:25:08 GMT',
        'Content-Length': 4838,
        'Content-MD5': '643dbefc61cbdb5accbe78dde7df5c8e',
        Authorization: 'NOS b281de474942444d889b33307a3b067e:03HihaIj5PWwtG5ix1W2mBBAumcgJlfKK3V03bHySwQ=' },
     body: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 50 00 00 00 50 08 06 00 00 00 8e 11 f2 ad 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 65 00 ... > } }

I looked around some issues, #5488 #5436, but still do not know how to solve this problem. And here is the output of dig nos.netease.com and nslookup nos.netease.com

; <<>> DiG 9.8.3-P1 <<>> nos.netease.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37195
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;nos.netease.com.       IN  A

;; ANSWER SECTION:
nos.netease.com.    289 IN  A   223.252.216.61
nos.netease.com.    289 IN  A   223.252.216.50
nos.netease.com.    289 IN  A   223.252.216.51
nos.netease.com.    289 IN  A   223.252.216.56
nos.netease.com.    289 IN  A   223.252.216.57
nos.netease.com.    289 IN  A   223.252.216.60

;; Query time: 7 msec
;; SERVER: 192.168.130.33#53(192.168.130.33)
;; WHEN: Mon Aug  1 10:37:45 2016
;; MSG SIZE  rcvd: 129
Server:     192.168.130.33
Address:    192.168.130.33#53

Non-authoritative answer:
Name:   nos.netease.com
Address: 223.252.216.51
Name:   nos.netease.com
Address: 223.252.216.56
Name:   nos.netease.com
Address: 223.252.216.57
Name:   nos.netease.com
Address: 223.252.216.60
Name:   nos.netease.com
Address: 223.252.216.61
Name:   nos.netease.com
Address: 223.252.216.50
@mscdex
Copy link
Contributor

mscdex commented Aug 1, 2016

Did you try explicitly setting family: 4 in your request options?

@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Aug 1, 2016
@zyy7259
Copy link
Author

zyy7259 commented Aug 1, 2016

@mscdex After setting family: 4, there is no error anymore. (I rerun the batch task ten times.)

I look up the api doc, it says

family: IP address family to use when resolving host and hostname.
Valid values are 4 or 6.
When unspecified, both IP v4 and v6 will be used.

I think it's an optional parameter. And before setting family: 4 most of the batch tasks still succeed. Only several failed. Can you explain why I have to set this?

@mscdex
Copy link
Contributor

mscdex commented Aug 1, 2016

Probably the OS is looking up an AAAA record (which does not exist for the hostname you've shown) because the network interface that your request is being sent through has an IPv6 address and that is being favored over IPv4. By default, node will just use whatever address that is returned by the OS. By explicitly telling the OS what type of address you want, it will return the address(es) you're expecting since A records for that hostname exist.

@bnoordhuis
Copy link
Member

Answered, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants