title: Nodejs & socket io Error: listen EADDRINUSE
body: <p>I am giving a try to do a chat with Node.js and socket.io</p>
  
  <p>Now here is my scenario I am using ubuntu 12.04 user and i have folder pp on desktop</p>
  
  <p>inside that i am putted server file <code>server.js</code></p>
  
  <p>Here is the client:</p>
  
  <pre><code>$(document).ready(function() {
      var urlServer = location.origin + ':8081';
      var socket = io.connect(urlServer);
  });
  
  $(document).ready(function() {
      var urlServer = location.origin + ':8081';
      var socket = io.connect(urlServer);
  
      $("#boton").on('click', function() {
          var mensaje = $("#mensaje").val();
          socket.emit("mensaje", {msg: mensaje});
      });
  
      socket.on("mensaje", function(msg) {
          console.log("hemos recibido un mensaje", msg);
      });
  });
  </code></pre>
  
  <p>And here the server</p>
  
  <pre><code>var server  = require('http').createServer(),
      sio      = require('socket.io'),
      port    = 8081;
  server.listen(port);
  var io = sio.listen(server, { log:true });
  var channels = {};
  io.sockets.on('connection', function (socket) {
      console.log("Cliente conectado");
  
      socket.on('mensaje', function (msg) {
          console.log(msg);
      socket.broadcast.emit('mensaje', msg);
      });
  
  });
  console.log('1- Escuchando en http://localhost:' + port , "");
  console.log("");
  </code></pre>
  
  <p>Now in the same folder I have an html file like</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script src="../jquery.js"&gt;&lt;/script&gt;
      &lt;script src="../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io"&gt;&lt;/script&gt;
      &lt;script src="clientechat.js.js"&gt;&lt;/script&gt;
      &lt;title&gt;Chat con Node&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;div id="mensajes"&gt;&lt;/div&gt;
      &lt;input type="text"&gt;
      &lt;input type="submit" id="boton"&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>when i am trying to run the app.js useing node like </p>
  
  <pre><code>node server.js
  </code></pre>
  
  <p>I am getting the error </p>
  
  <pre><code>   warn  - error raised: Error: listen EADDRINUSE
  </code></pre>
  
  <p>I try to restart all but it doesn't works</p>
  
  <p>Please tell me what might I am doing wrong.</p>