Error: getaddrinfo ENOTFOUND in nodejs for get call

后端 未结 10 748
离开以前
离开以前 2020-11-30 00:24

I am running a web server on node the code for which is given below

var restify = require(\'restify\');

var server = restify.createServer();

var quotes = [         


        
10条回答
  •  一个人的身影
    2020-11-30 01:11

    I was running into the same problem and after some trial and error discovered that my hosts file customisation was causing the problem.

    My localhost DNS was overwritten and because of that a simple ping was failing:

    $ ping http://localhost
    # ping: cannot resolve http://localhost: Unknown host
    

    Once I resolved the configuration of /private/etc/hosts file, pinging localhost successfully worked, and was no longer getting the error that you were seeing:

    # Fatal error: getaddrinfo ENOTFOUND
    

提交回复
热议问题