title: Socket.io works on localhost but not webserver
body: <p>I'm new to socket.io and have been able to get many examples from different tutorials working correctly on my localhost. Now I need help getting it to work on my website. I've been browsing support forms for days with no luck. Any help would be appreciated. Here is what I've done so far...</p>
  
  <p>I exported the code (which was working on my localhost) to my web server (hosted by <a href="https://ifastnet.com/" rel="nofollow">https://ifastnet.com/</a>) using FileZilla FTP Client and did the same "npm init", "npm install express --save", "npm install socket.io --save", "node app.js" procedure on putty SSH that I used on my CMD when I was able to get it to work on my localhost. </p>
  
  <p>When I go to my website I keep getting "net::ERR_CONNECTION_RESET" in the browser console (google chrome) when I use</p>
  
  <pre><code>var socket = io.connect('http://31.22.4.6:1122');
  </code></pre>
  
  <p>on the client side.</p>
  
  <p>I get "404 (Not Found)" in the browser console when I use</p>
  
  <pre><code>var socket = io();
  </code></pre>
  
  <p>I've tried many solutions with no luck</p>
  
  <p>My code is below. Thanks in advance for the help.</p>
  
  <p>server</p>
  
  <pre><code>var app = require('express')();
  var server = require('http').Server(app);
  var io = require('socket.io')(server);
  
  server.listen();
  // server.listen(1122, "31.22.4.6");
  
  app.get('/', function(req, res) {
      res.sendfile(__dirname + '/client/index.html');
  });
  
  console.log("server started");
  
  
  io.on('connection', function(socket) {
      console.log("connection made");
      socket.emit('news', {
          hello: 'world'
      });
      socket.on('my other event', function(data) {
          console.log(data);
      });
  });
  </code></pre>
  
  <p>client</p>
  
  <pre><code>&lt;script src="https://cdn.socket.io/socket.io-1.4.5.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    // var socket = io.connect('http://localhost');
    // var socket = io.connect('http://31.22.4.6:1122');
    var socket = io();
    // var socket = io.connect();
    socket.on('news', function (data) {
      console.log(data);
      socket.emit('my other event', { my: 'data' });
    });
  &lt;/script&gt;
  </code></pre>