Error: getaddrinfo ENOTFOUND
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.
I met the same issue and solved it!
try:
sudo vi /etc/hosts
and add:
127.0.0.1 localhost
to hosts
I had this issue becuase there was a typo in my URL - the path did not exist. Gotta be careful with long subdomain URLs. I discovered the issue while using the Postman Console - available by going to View > Show Postman Console.