title: Error node.js Failed to load resource
body: <p>I have been working with node.js and socket.io, and following a tutorial, but I keep getting an error from an application I am building. This is my server.js file:</p>
  
  <pre><code>var static = require('node-static');
  var http = require('http');
  var file = new(static.Server)();
  var app = http.createServer(function(req, res) {
      file.serve(req, res);
  }).listen(1234);
  var io = require('socket.io').listen(app);
  io.sockets.on('connection', function(socket) {
      function log() {
          var array = ["&gt;&gt;&gt; Message from server: "];
          for (var i = 0; i &lt; arguments.length; i++) {
              array.push(arguments[i]);
          }
          socket.emit('log', array);
      }
      socket.on('message', function(message) {
          log('Got message:', message);
          socket.broadcast.emit('message', message);
      });
      socket.on('create or join', function(room) {
          var numClients = io.sockets.clients(room).length;
          log('Room ' + room + ' has ' + numClients + ' client(s)');
          log('Request to create or join room ' + room);
          if (numClients === 0) {
              socket.join(room);
              socket.emit('created', room);
          } else if (numClients === 1) {
              io.sockets.in(room).emit('join', room);
              socket.join(room);
              socket.emit('joined', room);
          } else { // max two clients
              socket.emit('full', room);
          }
          socket.emit('emit(): client ' + socket.id + ' joined room ' + room);
          socket.broadcast.emit('broadcast(): client ' + socket.id + 'joined room' + room);
      });
  });
  </code></pre>
  
  <p>However when I browse to <code>localhost:1234</code> I get the error <code>Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:1234</code></p>