title: SocketIO ERR_CONNECTION_REFUSED
body: <p>I am starting to use NodeJS and Socket.IO. I am trying to set up a basic example with a NodeJS http server and establish a Socket.IO connection to the server. </p>
  
  <p>I am also using angular JS and basically what I want is that when a user presses a button then the connection to the server is established. However, when I try it I get this error </p>
  
  <p><code>GET http://localhost/socket.io/?EIO=2&amp;transport=polling&amp;t=1404288173776-3 net::ERR_CONNECTION_REFUSED</code></p>
  
  <p><strong>Here is my code:</strong></p>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>var http = require('http');
  var server= http.createServer(handler);
  var io = require('socket.io')(server);
  
  server.listen(8080);
  
  function handler(req, res) {
      res.writeHead(200);
      res.end('Hello Http');
  }
  
  io.on('connection', function (socket){
      socket.emit('news', { hello: 'world' });
      console.log('connected!');
  });
  </code></pre>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var app = angular.module('testApp', ['ngRoute']);
  
  app.controller('TestCtrl', function ($scope){
  
      $scope.msg= "";
  
      $scope.try = function (){
  
          $scope.msg= "ALO"
  
          var socket = io('http://localhost');
  
          socket.on('news', function (data) {
              console.log(data);
          });
  
      };
  
  });
  </code></pre>
  
  <p>And on my test.html file:</p>
  
  <pre><code>&lt;body ng-controller="TestCtrl"&gt;
  
      &lt;h2&gt;{{msg}}&lt;/h2&gt;
      &lt;button ng-click="try()"&gt;Try&lt;/button&gt;
  
      &lt;script src="../js/angular.min.js"&gt;&lt;/script&gt;
      &lt;script src="../js/angular-route.min.js"&gt;&lt;/script&gt;
      &lt;script src="../js/app.js"&gt;&lt;/script&gt;
  
      &lt;script src="../node_modules/socket.io/node_modules/socket.io-client/socket.io.js"&gt;&lt;/script&gt;
  
  &lt;!-- &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt; --&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>I think that the error might be something related to the path I use when including the socket.io.js I have tried also using directly localhost:8080 in the path because I read it could be a solution but that didn't work. So please, I appreciate any help given. Thanks!</p>