title: Node.js - Socket.io only accessible through localhost
body: <p>When I run my Node.js script, I can only access it by using localhost:8083, while using the machine's IP address from another device results in a "This site cannot be reached". I am using the following Node.js <strong>server script</strong>:</p>
  
  <pre><code>var app = require('express')(),
      server = require('http').createServer(app),
      io = require('socket.io').listen(server),
      ent = require('ent'), // Blocks HTML characters (security equivalent to htmlentities in PHP)
      fs = require('fs');
  
  // Loading the page index.html
  app.get('/', function (req, res) {
    res.sendfile(__dirname + '/index.html');
  });
  
  io.sockets.on('connection', function (socket, username) {
      // When the username is received it’s stored as a session variable and informs the other people
      socket.on('new_client', function(username) {
          username = ent.encode(username);
          socket.username = username;
          socket.broadcast.emit('new_client', username);(err) {});
      });
  
      // When a message is received, the client’s username is retrieved and sent to the other people
      socket.on('message', function (message) {
          message = ent.encode(message);
          socket.broadcast.emit('message', {username: socket.username, message: message});
      }); 
  });
  console.log('Chat Socket.io running on port 8083');
  server.listen(8083);
  </code></pre>
  
  <p>Here is the <strong>client script</strong>:</p>
  
  <pre><code>&lt;script src = "http://code.jquery.com/jquery-1.10.1.min.js" &gt; &lt;/script&gt;
  &lt;script src="/socket.io / socket.io.js "&gt;&lt;/script&gt;
  &lt;script&gt;
      // Connecting to socket.io
      var socket = io.connect("10.254.17.115:8083");
  
      // The username is requested, sent to the server and displayed in the title
      var username = prompt('What\'s your username?');
      socket.emit('new_client', username);
      document.title = username + ' - ' + document.title;
  
      // When a message is received it's inserted in the page
      socket.on('message', function(data) {insertMessage(data.username, data.message)})
  
      // When a new client connects, the information is displayed
      socket.on('new_client', function(username) {
      $('#chat_zone').prepend(
          '&lt;p&gt;&lt;audio class="background" autoplay&gt;&lt;source src="new-user.mp3" type="audio/wav"&gt;&lt;/audio&gt;&lt;em&gt;' + username + ' has joined the chat!&lt;/em&gt;&lt;/p&gt;');
      })
  
      // When the form is sent, the message is sent and displayed on the page
      $('#chat_form').submit(function() {
          var message = $('#message').val();
          socket.emit('message', message); // Sends the message to the others
          insertMessage(username, message); // Also displays the message on our page
          $('#message').val('').focus(); // Empties the chat form and puts the focus back on it
          return false; // Blocks 'classic' sending of the form
      });
  
      // Adds a message to the page
      function insertMessage(username, message) {
          $('#chat_zone').prepend('&lt;p&gt;&lt;strong&gt;' + username + '&lt;/strong&gt; ' + message + '&lt;/p&gt;');
      } 
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Edit:</strong> Revised ports but they were not the issue. When I changed the <code>var socket = io.connect</code> to <code>io()</code> it worked.</p>