0

I am trying to write a node.js script as follows

var https = require('https');
var options = {
  hostname: 'https://172.16.2.51',
  port: 9090,
  path: '/vm/list',
  method: 'GET',                
};

var req = https.request(options, function(res) {
  res.on('data', function(d) {
    process.stdout.write(d);
  });
});

req.end();
req.on('error', function(e) {
  console.error(e);
});

When I run the script, I get this error:

{ [Error: getaddrinfo ENOENT] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }

1 Answer 1

3

The hostname property of options should be an IP address or a domain name. In your example, get rid of the protocol. So change this:

var options = {
  hostname: 'https://172.16.2.51',
  port: 9090,
  path: '/vm/list',
  method: 'GET'
};

To this:

var options = {
  hostname: '172.16.2.51',
  port: 9090,
  path: '/vm/list',
  method: 'GET'
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.