I am troubleshooting a Node.js script, and have stripped out almost all of the code and still am able to reproduce the following error:
{ [Error: connect ECONNREFUSED] stack: 'Error: connect ECONNREFUSED at exports._errnoException (util.js:682:11) at Object.afterConnect [as oncomplete] (net.js:947:19)', code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' }
The entire script is:
var http = require('http'); http.get("http://api.hostip.info/get_json.php", function(res) { console.log("Received response: " + res.statusCode); }); var req = http.request(function(res) { console.log("Request began"); var output = ''; res.on('data', function (chunk) { output += chunk; }); res.on('end', function () { console.log('Request complete:'); console.log(output); }); }); req.on('error', function (err) { console.log(err); //console.log('error: ' + err.message); }); req.end(); console.log("Script complete");
I'm confident this is a simple mistake somewhere in the code, but have been unable to identify the problem?