Nodejs Https get Error: getaddrinfo ENOTFOUND
11,770
Solution 1
Obviously the domain you used is not valid.
Solution 2
probably it's because of SSL authentication in loopback, can you please try this npm package
Solution 3
URL shouldn't contain https://
modify url
from
var URL = 'https://mobileapp.mydomain.com/api/uuids?filter[where][uuid]='+uid;
to var URL = 'mobileapp.mydomain.com/api/uuids?filter[where][uuid]='+uid;
I had this issue and this resolved it.
Author by
RSA
Updated on September 03, 2022Comments
-
RSA over 1 year
I'm trying to get a
filtered
record fromloopback
, but I don't understand whynodejs
gives error on fallowing commands:const https = require('https'); var uid = '02644da038b37d7ba70b7ee1a92ba1d9'; var URL = 'https://mobileapp.mydomain.com/api/uuids?filter[where][uuid]='+uid; https.get(URL, (res) => { console.log('statusCode:', res.statusCode); console.log('headers:', res.headers); res.on('data', (d) => { process.stdout.write(d); }); }).on('error', (e) => { console.error('ERROR:',e); });
the error on output:
ERROR: { Error: getaddrinfo ENOTFOUND mobileapp.mydomain.com mobileapp.mydomain.com:443 at errnoException (dns.js:28:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26) code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'mobileapp.mydomain.com', host: 'mobileapp.mydomain.com', port: 443 }
-
robertklep over 6 yearsIt can't resolve the hostname
mobileapp.mydomain.com
into an IP-address. -
RSA over 6 yearsI don t know why but
nslookup
resolve subdomain and shows staticipaddres
-
robertklep over 6 yearsAre you using some sort of antivirus or firewalling software that may block DNS lookups from Node?
-
RSA over 6 yearsNo there is no any antivirus or firewall it is win 2008 based VPS.
-
-
RSA over 6 yearswhen I put URL
https://mobileapp.mydomain.com/api/uuids?filter[where][uuid]=02644da038b37d7ba70b7ee1a92ba1d9
the result is ajson
. -
A-yon Lee over 6 yearsHave a look at you
hosts
file, I think you're mis-pointingmobileapp.mydomain.com
to a specific IP address, which can not be recognized on the internet. -
RSA over 6 yearsCan I use request method?
-
A-yon Lee over 6 yearsI tried to
ping mobileapp.mydomain.com
, it cannot be recognized, see if your shell output something contains[127.0.0.1]
? -
RSA over 6 yearsI have static IP address of my domain and subdomain. I was using node 6.3.1 and upgrade to 8.5.0 and now looks ok.