abdulbari
abdulbari

Reputation: 6242

Error: "tunneling socket could not be established, cause=getaddrinfo ENOTFOUND" code: 'ECONNRESET'

I am using node wget to download files from URL and I am getting this error. If I use simple wget command to download files it working fine, but I want download file from node module here is my code

var wget = require('wget');

var router = express.Router();

/* GET home page. */
router.get('/', function(req, response) {
  var options = {
  protocol: 'https',
  host: 'raw.github.com',
  path: '/Fyrd/caniuse/master/data.json',
  proxy: 'http://host:port',
  method: 'GET'
};
var req = wget.request(options, function(res) {
  var content = '';
  if (res.statusCode === 200) {
    res.on('error', function(err) {
        console.log(err);
    });
    res.on('data', function(chunk) {
        content += chunk;
    });
    res.on('end', function() {
        console.log(content);
    });
  } else {
    console.log('Server respond ' + res.statusCode);
  }
});

req.end();
req.on('error', function(err) {
console.log(err);
});
response.render('index', { title: 'Express' });
});

module.exports = router;

Upvotes: 0

Views: 9165

Answers (1)

Evers
Evers

Reputation: 1908

I stumble upon this question. This is probably caused by the proxy not supporting HTTPS. Try a proxy that supports HTTPS and the problem should be solved.

Upvotes: 0

Related Questions