Net server in startup gives connection refused

I published my application in Amazon AWS with this code in the application startup :

var net = Npm.require('net');
Fiber = Npm.require('fibers');
var server = net.createServer(function(c) {
  console.log('Client Conected');
    console.log("Recived: "+ data.toString());
  c.on('end', function() {
    console.log('Client Disconected');
server.listen(8124, function() {
  console.log('Gateway Started');

When I try to send data over telnet I get connection refused and if I run code in pure nodejs server can connect , anyone have any idea what can be ?

I’m using the mupx to deploy in aws

Thank you!

someone has an idea ?