title: Socket.io client can not connect to localhost while it can connect to 127.0.0.1
body: <p>I have a server set up using node.js and I'm trying to connect to the server with socket.io. The server used to work perfectly 2 months ago but for some reason it does not work anymore. The server code looks like the following:</p>
  
  <pre><code>var http = require('http');
  var server = http.createServer(function (request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.end("Hello World\n");
  });
  
  var io = require('socket.io')(server);    
  
  io.sockets.on('connection', function (socket) {
   console.log ('Client connected.'); });
  
  console.log ('Server started.');
  server.listen(3000, '0.0.0.0');
  </code></pre>
  
  <p>On my client side, I'm using the line</p>
  
  <pre><code>socket = io.connect("http://localhost:3000");
  </code></pre>
  
  <p>to try to connect to my server, but it doesn't work. The connection works perfectly if I use the line</p>
  
  <pre><code>socket = io.connect("http://127.0.0.1:3000");
  </code></pre>
  
  <p>If I type localhost:3000 on the browser, it sends me to the page saying Hello World as intended, same as 127.0.0.1, so it is not working only when I'm using io.connect.</p>
  
  <p>Things that I have tried are:</p>
  
  <ul>
  <li>changing the host file (adding the line 127.0.0.1 localhost, removing the line including ::1, making a new host file and overwriting it)</li>
  <li>trying it on a different machine, still the same problem</li>
  <li>resetting the router settings.</li>
  <li>pinging localhost on a cmd prompt, it says reply from ::1: time&lt;1ms</li>
  <li>installing different version of socket.io and node.js (both the most recent ones and versions 2 months ago)</li>
  </ul>
  
  <p>Considering what happens from web browser, localhost seems to work but it only does not work when I use socket.io with it. I have been unable to solve this problem that suddenly appeared, so I would appreciate it a lot if someone can give me some insights on what can be causing this.</p>