nodejs httprequest with data - getting error getaddrinfo ENOENT

后端 未结 8 1724
天命终不由人
天命终不由人 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:14

    I hit this again today for a silly mistake. This was because port number was put as part of the hostname.

    // wrong. gets error getaddrinfo ENOENT
    var options = {
      hostName: 'localhost:1337',
      ....
    }
    
    // correct
    var options = {
        hostname: 'localhost',
        port: 1337,
    };
    

提交回复
热议问题