nodejs httprequest with data - getting error getaddrinfo ENOENT

后端 未结 8 1694
天命终不由人
天命终不由人 2020-12-02 22:47

Update - Answered by self

I see one has to make sure that the DNS is resolved properly from the machine, check out the node documentation to make sure that domain

8条回答
  •  伪装坚强ぢ
    2020-12-02 23:15

    If all your code seems to be alright and you're still get the same error, which was my case, the solution was checking the nameservers on my /etc/resolv.conf file.

    I added Google's nameserver at the beginning of my resolv.conf file (8.8.8.8) and the code started working just fine once again, no more error.

    It's worth noticing that this error started happening on me on Feb. 4th 2015 after I ran an sudo apt-get upgrade, my node js must have been updated and a bug introduced which seemed to be incompatible with the nameservers I had.

    At first I checked if I was having any DNS issues by fetching the URL I needed using wget on the command line, I got the contents of the target url fine so I didn't think it was actually a DNS issue, but it was.

提交回复
热议问题