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.

Share:
11,770
RSA
Author by

RSA

Updated on September 03, 2022

Comments

  • RSA
    RSA over 1 year

    I'm trying to get a filtered record from loopback, but I don't understand why nodejs 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
      robertklep over 6 years
      It can't resolve the hostname mobileapp.mydomain.com into an IP-address.
    • RSA
      RSA over 6 years
      I don t know why but nslookup resolve subdomain and shows static ipaddres
    • robertklep
      robertklep over 6 years
      Are you using some sort of antivirus or firewalling software that may block DNS lookups from Node?
    • RSA
      RSA over 6 years
      No there is no any antivirus or firewall it is win 2008 based VPS.
  • RSA
    RSA over 6 years
    when I put URL https://mobileapp.mydomain.com/api/uuids?filter[where][uuid]‌​=02644da038b37d7ba70‌​b7ee1a92ba1d9 the result is a json.
  • A-yon Lee
    A-yon Lee over 6 years
    Have a look at you hosts file, I think you're mis-pointing mobileapp.mydomain.com to a specific IP address, which can not be recognized on the internet.
  • RSA
    RSA over 6 years
    Can I use request method?
  • A-yon Lee
    A-yon Lee over 6 years
    I tried to ping mobileapp.mydomain.com, it cannot be recognized, see if your shell output something contains [127.0.0.1]?
  • RSA
    RSA over 6 years
    I 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.