Skip to content Skip to sidebar Skip to footer

"Error: Getaddrinfo ENOTFOUND" Error When Making An HTTPs Request

here's the code in AWS Lambda function: var https = require('https'); exports.handler = (event, context, callback) => { var params = { host: 'bittrex.com', p

Solution 1:

Remove the https:// from the host. The require already says you're using https/SSL.


Solution 2:

I modified your code to work correctly in AWS Lambda Node.js 6.10. I set the Lambda timeout to be 60 seconds for testing.

The big change is adding "res.on('data', function(chunk) {}:" and "res.on('end', function() {}".

var https = require('https');
exports.handler = (event, context, callback) => {
    var params = {
        host: "bittrex.com",
        path: "/api/v1.1/public/getmarketsummaries"
    };
    var req = https.request(params, function(res) {
        let data = '';
        console.log('STATUS: ' + res.statusCode);
        res.setEncoding('utf8');
        res.on('data', function(chunk) {
            data += chunk;
        });
        res.on('end', function() {
            console.log("DONE");
            console.log(JSON.parse(data));
        });
    });
    req.end();
};

Solution 3:

The issue is with your security groups. Looks like your lambda doesn’t have access to resolve DNS. Check if you lambda sec groups have port 53 UDP and TCP enabled.


Post a Comment for ""Error: Getaddrinfo ENOTFOUND" Error When Making An HTTPs Request"