title: node js server doesn't get started
body: <p>I have a server.js file that will be used to start a node server and do some tasks. But when i run the file, the server doesn't getting started. Even i have catch the error it doesn't give me any errors. Any help would be appriciated!</p>
  
  <p>Thanks.</p>
  
  <p>below is my server.js file code block,</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var request = require('request');
  var fs = require('fs');  
  
  //--ssl files for the socket.io
  var options = {
  
  key: fs.readFileSync('pre3private.key'),
  
  cert: fs.readFileSync('pre3cert.cert')
  
  };
  //--/ssl files for the socket.io 
  
  var https = require('https').Server(options, app);
  var io = require('socket.io')(https);
  var net = require('net'); 
  
  var check_port = 8081; 
  
  var server = net.createServer();
  
  server.once('error', function(err) {
   console.log(err);
   if (err.code === 'EADDRINUSE') {
    // port is currently in use
    check_port += 1;
    if(check_port === 8050) { check_port = 8000; }
    server.listen(check_port);
   }
  });
  
  server.once('listening', function() {
   // close the server if listening doesn't fail
   server.close();
  
   var port = process.env.PORT || check_port;
  
   https.listen(port, function(){
    debug('Server started! at port ' + port);
   });                 
  
  });
  </code></pre>