EAI_AGAIN is a DNS lookup timeout error⌠The Stack Overflow link below has an explanation and references to other links that may help:
Error: getaddrinfo EAI_AGAIN
You get add and fam as undefined because, since the lookup fails, theyâre not set.
Also, a host name is the server name, not the URL, so youâd want to use
forum.freecodecamp.org
not
https://forum.freecodecamp.org
in the lookup
dns.lookup("forum.freecodecamp.org", (err, add, fam) => {
console.log("err: " + err, "add: " + add, "fam: " + fam);
});
The node.js dns.lookup documentation is at dns.lookup(hostname[, options], callback)
You might also find Katacoda Node.js Playground useful. You can use it to try out snippets of code. You can try this snippet from the node.js documentation in it and see what should be returned:
const dns = require('dns');
const options = {
family: 6,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};
dns.lookup('example.com', options, (err, address, family) =>
console.log('address: %j family: IPv%s', address, family));
Be sure to change âexample.comâ to a real host name like âwww.google.comâ.