title: node.js error ECONNREFUSED on localhost url only
body: <p>I have a node app, hosted on heroku, where I'm trying to hit an API that returns some JSON. That API I'm calling lives with the same app that I'm calling it from (e.g. The node app hosts my web app and has an API that generates JSON from my db). </p>
  
  <p>I'm using the request npm module to make my API call. When deployed to heroku, when I use localhost:8080 as the url in the function I get the error below, but when I use the actual url where my app is hosted on heroku, it works fine. I have dev/staging/prod environments so I don't want to hard code the url. </p>
  
  <p>Thing is, it works fine locally on my machine, so I'm not sure what the issue is - I'm assuming it has something to do with heroku since that's the only difference, but I'm not very familiar with this type of error.</p>
  
  <p>Also - if it helps, I can hit both urls in the browser fine, locally, and on the heroku app.  </p>
  
  <pre><code>request('http://localhost:8080/api/pictures', function (error, response, body) {
    // this throws error: "connect ECONNREFUSED"
  });
  
  request('http://myapp.herokuapp.com/api/pictures', function (error, response, body) {
     // this works
  });
  </code></pre>