title: Heroku Node.js + Socket.io: After deploying to Heroku, I get a ERR_CONNECTION_REFUSED
body: <p>This is the error message I am getting in the web console on my live node.js heroku app: <code>polling-xhr.js:264 GET http://localhost:3000/socket.io/?EIO=3&amp;transport=polling&amp;t=M2MDZUw net::ERR_CONNECTION_REFUSED</code></p>
  
  <p>When I run my program locally, it all works fine without any problem. I have listed the server to listen to whatever is in the environment <code>PORT</code> or port <code>3000</code> if there's nothing there. Below is my relevant <code>server.js</code> code, and <code>package.json</code> code, as well as the client code used to connect to the server.</p>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>var express = require("express");
  var socket = require("socket.io");
  
  var app = express();
  var server = app.listen(process.env.PORT || 3000)
  </code></pre>
  
  <p><strong>package.json</strong></p>
  
  <pre><code>{
    "name": "testProject",
    "version": "1.0.0",
    "description": "test project using node.js + sockets.io",
    "main": "server.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1"
    },
    "keywords": [
      "sockets",
      "p5",
      "node"
    ],
    "author": "henry zhu",
    "license": "ISC",
    "dependencies": {
      "express": "^4.16.2",
      "socket.io": "^2.0.4"
    }
  }
  </code></pre>
  
  <p>Client-side code to connect to server:</p>
  
  <pre><code>var socket = io.connect("http://localhost:3000");
  </code></pre>
  
  <p>The version of socket.io I am using client side is 2.0.4.</p>