title: Chat application won't run on port 80 with socket.io and node.js./express
body: <p>I'm trying to implement the most rudimentary socket.io/node.js application on my site. I want to take run it on port 80(http) instead of port 3000 in the app.js, for whatever reason, it breaks the whole application server side. I am literally only changing server.listen(3000) to server.listen(80), and it breaks the application. Here's the app.js, and the client side script. I'm not that great with stack formatting so forgive me.</p>
  
  <p><strong>Server Side App.Js:</strong></p>
  
  <pre><code>var express=require('express'),
  app = express(),
  server = require('http').createServer(app),
  io = require('socket.io').listen(server),
  nicknames = [];
  
  
  server.listen(3000);
  
  app.get('/', function(req, res){
  res.sendFile(__dirname + '/chat.html');
  
  });
  
  
  io.sockets.on('connection', function(socket){
  socket.on('new user', function(data, callback){
      if(nicknames.indexOf(data) != -1){
          callback(false);
      }
      else{
          callback(true);
          socket.nickname = data;
          nicknames.push(socket.nickname);
          io.sockets.emit('usernames', nicknames);
      }
  
  });
  socket.on('send message', function(data){
      io.sockets.emit('pushMessage', {msg: data, nick: socket.nickname});
  
  
  });
  
  socket.on('disconnect', function(data){
      if(!socket.nickname) return;
      nicknames.splice(nicknames.indexOf(socket.nickname), 1);
      io.sockets.emit('usernames',nicknames);
  
  });
  });
  </code></pre>
  
  <p>Client HTML/JS:</p>
  
  <pre><code>    &lt;html&gt;
      &lt;head&gt;
      &lt;script   src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"&gt;&lt;/script&gt;
       &lt;title&gt;SchoolChat&lt;/title&gt;
       &lt;style&gt;
      #chat{
      height:500px;
      }
      #mainWrap{
      display:none;
      } 
      #chatWrap{
      float: left;
      border:1px #000 solid;
  
      }
  
  #chat {
      list-style-type: none;
      margin:0;
      padding:0;
  
  }
  #chat li {
      padding:5px 10px;
  
  }
  
  #chat li: nth-child(odd) {
      background:#eee;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="nickWrap"&gt;
  &lt;p&gt;Enter a Username&lt;/p&gt;
  &lt;p id="nickError"&gt;&lt;/p&gt;
  &lt;form id="setUser"&gt;
  &lt;input size="35" id="userName"&gt;&lt;/input&gt;
  &lt;input type="submit"&gt;&lt;/input&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  
      &lt;div id="mainWrap"&gt;
      &lt;div id="chatWrap"&gt;
          &lt;ul id="chat"&gt;&lt;/ul&gt;
          &lt;form id="send-message"&gt;
          &lt;input size="35" id="message"&gt;&lt;/input&gt;
          &lt;input type="submit"&gt;&lt;/input&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;div id="users"&gt;&lt;/div&gt;
      &lt;/div&gt;
  
  
  
      &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
      &lt;script&gt;
      jQuery(function($){
          var socket = io.connect();
          var $messageForm = $('#send-message');
          var $usernameForm = $("#setUser");
          var $userName = $("#userName");
          var $nickError = $("nickError");
          var $nickBox= $('#nickWrap');
          var $messageBox = $('#message');
          var $chat = $('#chat');
  
              $usernameForm.submit(function(e){
                  e.preventDefault();
                  socket.emit('new user', $userName.val(), function(data){
                  if (data){
                      $("#nickWrap").hide();
                      $("#mainWrap").show();
                  }
                  else{
                      $("#nickError").html('That username is already in use.');
  
                  }
  
  
  
                  });
                  $nickBox.val('')
              });
  
              socket.on('usernames', function(data){
                  var html= " ";
                  for(i=0; i&lt;data.length; i++){
                      html += data[i] + '&lt;/br&gt;'
  
                  }
                  $('#users').html(html);
  
              });
  
          $messageForm.submit(function(e){
              e.preventDefault();
              socket.emit('send message', $messageBox.val());
              $messageBox.val("");
  
          });
  
  
  
          socket.on('pushMessage', function(data){
              $chat.append("&lt;li&gt;&lt;b&gt;" + data.nick+ ":" + "&lt;/b&gt;" + data.msg+ "&lt;/li&gt;");
  
  
              });
  
      });
          &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>