Error: getaddrinfo ENOTFOUND

血红的双手。 提交于 2019-12-05 04:26:48
William

I met the same issue and solved it!

try:

sudo vi /etc/hosts

and add:

127.0.0.1 localhost

to hosts

The symptom is that the remote address cannot be resolved.

The cause could be many things. First, try to see if it's node specific by trying to resolve the address directly:

$ nslookup www.rest-api.com

Or:

$ dig www.rest-api.com

If that doesn't work, you've got a connectivity problem. It could be anything. Try looking at how long your DHCP lease lasts if you are using DHCP.

However if that does work fine but your node application still fails, you might be running into this: https://github.com/nodejs/node/issues/5436 , which is a bug in an underlying library. You can implement the workaround mentioned in that thread, which is specifying the IP version family through the following parameter { family: 4 } as a part of your request options.

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