title: Cannot connect to localhost using Socket io example
body: <p>I have been following along to the socket io chat example and I CANNOT get it to connect to the localhost! I have done it over and over again and it is really frustrating. Here is the example I have been following:</p>
  
  <p><a href="http://socket.io/get-started/chat/" rel="nofollow">http://socket.io/get-started/chat/</a></p>
  
  <p>Here is the index:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Socket.IO chat&lt;/title&gt;
      &lt;style&gt;
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font: 13px Helvetica, Arial; }
        form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
        form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
        form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
        #messages { list-style-type: none; margin: 0; padding: 0; }
        #messages li { padding: 5px 10px; }
        #messages li:nth-child(odd) { background: #eee; }
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;ul id="messages"&gt;&lt;/ul&gt;
      &lt;form action=""&gt;
        &lt;input id="m" autocomplete="off" /&gt;&lt;button&gt;Send&lt;/button&gt;
      &lt;/form&gt;
      &lt;script src="https://cdn.socket.io/socket.io-1.2.0.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/jquery-1.11.1.js"&gt;&lt;/script&gt;
      &lt;script&gt;
        var socket = io();
        $('form').submit(function(){
          socket.emit('chat message', $('#m').val());
          $('#m').val('');
          return false;
        });
        socket.on('chat message', function(msg){
          $('#messages').append($('&lt;li&gt;').text(msg));
        });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>here is index.js :</p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  
  app.get('/', function(req, res){
   res.sendFile(__dirname + '/index.html');
  });
  
  io.on('connection', function(socket){
    socket.on('chat message', function(msg){
      io.emit('chat message', msg);
    });
  });
  
  http.listen(3000, function(){
    console.log('listening on *:3000');
  });
  </code></pre>
  
  <p>and here is the package.json :</p>
  
  <pre><code>{
    "name": "socket-chat-example",
    "version": "0.0.1",
    "description": "my first socket.io app",
    "dependencies": {
      "express": "^4.10.2",
      "socket.io": "^1.2.0"
    }
  }
  </code></pre>
  
  <p>I've tried everything and it always gives:</p>
  
  <blockquote>
    <p>"Failed to load resource: the server responded with a status of 404 (Not Found)"</p>
  </blockquote>
  
  <p>and even node <code>index.js</code> will not even start listening! </p>