Node.js unhandled 'error' event

express, http, javascript, node.js, port

Solution

For me, the problem was another instance was running. Search for other node instance running and kill it. It should resume properly after.

Problem

I have written a simple code and save it in file try.js . ``` var http = require('http'); var makeRequest = function(message) { var options = { host: 'localhost', port: 8080, path: '/', method: 'POST' } var request = http.request(options, function(response){ response.on('data', function(data){ console.log(data); }); }); request.write(message); request.end(); } makeRequest("Here's looking at you, kid."); ``` When I run it through terminal it give an error ``` throw er; // Unhandled 'error' event, Error: connect ECONNREFUSED at errnoException (net.js:884:11) at Object.afterConnect [as oncomplete] (net.js:875:19)error' event ```

Original source