What ENOTFOUND error in an http request, happening time to time, means?

你离开我真会死。 提交于 2019-12-12 04:59:34

问题


I have a nodejs server, running on an hosted cloud machine. An http request

var req = Http.request(options, function(res) { ... }

with options

host: "www.mysite.com”    
port: "8080"
method: “GET”
path: “/someurl”

reply with this error sometimes (let's say one time out of ten)

{"code":"ENOTFOUND","errno":"ENOTFOUND","syscall":"getaddrinfo"}

Now, the question is what this error could mean.

The request seems to be correct (right path, right port, url alive and rocking, no http protocol included in path, the path is to a drupal page of a site running on the same machine) and it works almost all the time. Sometimes, with no apparent reason, it fails.

Recently, I noticed, on the machine, issues about ipv6 and I had to disable it on sysctl to make things work. The problem raised with suspicious precision after the issue about ipv6 showed up. Maybe this error is caused by some dns issues on the machine itself (so i have to blame my host)?


回答1:


It's DNS errors, specifically, Node can't resolve a hostname "www.mysite.com" to an IP-address.

There can be various reasons for this:

  • the hostname is just invalid
  • your network connection is faulty
  • your DNS server is faulty
  • the DNS server that handles "mysite.com" is faulty

As a heads-up: while your question is valid, debugging the underlying cause (DNS issues) is off-topic on StackOverflow.



来源:https://stackoverflow.com/questions/37272948/what-enotfound-error-in-an-http-request-happening-time-to-time-means

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!