I think you only have a typo, use res.endto send data and close the connection instead res.send.
In addition, you should not have problems connecting to localhost
var http = require('http');
http.createServer(function(req, res){
res.writeHead( 200, { "content-Type" : 'text/plain' } )
res.end('Hello world');
}).listen(1337, 'localhost');
source
share