title: Node js - Socket.io-client is not connecting to socket.io server
body: <p>I am trying to connect to a socket.io-client using the following code:</p>
  
  <p>Server:</p>
  
  <pre><code>// Load requirements
  var http = require('http'),
      io = require('socket.io');
  
  // Create server &amp; socket
  var server = http.createServer(function(req, res){
  
      // Send HTML headers and message
      res.writeHead(404, {'Content-Type': 'text/html'});
      res.end('&lt;h1&gt;Aw, snap! 404&lt;/h1&gt;');
  });
  server.listen(8080);
  io = io.listen(server);
  
  // Add a connect listener
  io.sockets.on('connection', function(socket) {
  
      console.log('Client connected.');
  
      // Disconnect listener
      socket.on('disconnect', function() {
          console.log('Client disconnected.');
      });
  });
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>console.log('1');
  
  // Connect to server
  var io = require('socket.io-client')
  var socket = io.connect('localhost:8080', {reconnect: true});
  
  console.log('2');
  
  // Add a connect listener
  socket.on('connect', function(socket) {
      console.log('Connected!');
  });
  
  console.log('3');
  </code></pre>
  
  <p>I don't get the Connected console log or Client Connected console log and I don't know why! The code sample is taken from another question posted: <a href="https://stackoverflow.com/questions/8837236/how-to-connect-two-node-js-servers-with-websockets">Link</a> and I don't see any solution to the problem... </p>