title: pointing node.js app to my ip address and running locally
body: <p>So I have two questions about the topic. I have purchased a VPS with digitalocean.com to host my node.js app and they gave me an example hello world app to start. </p>
  
  <pre><code>var http = require('http');
  http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  var html = "hello world";
  res.end(html);
  }).listen(8080, 'localhost');
  console.log('Server running at http://localhost:8080/');
  </code></pre>
  
  <p>So this code works locally and when I host on the VPS I replace 'localhost' with the IP address of my VPS and it is available on the web when I go to <a href="http://IP_Address_of_VPS:8080">http://IP_Address_of_VPS:8080</a></p>
  
  <p>My first question: How do I host it live on the web but have it point to my IP address? When I replace 'localhost' with my IP address it does not work when I go to <a href="http://my_IP_Address:8080" rel="nofollow">http://my_IP_Address:8080</a></p>
  
  <p>My second question: 
  I made a test app following a node.js tutorial and here is the code</p>
  
  <pre><code>var PORT = process.env.PORT || 8080;
  var express = require('express');
  var app = express();
  var http = require('http').Server(app);
  
  app.use(express.static(__dirname + '/public'));
  
  http.listen(PORT, function(){
  console.log('listening on port *:'+PORT);
  });
  </code></pre>
  
  <p>Where public is the folder with a simple html page. This app works when I run it locally at <a href="http://localhost:8080" rel="nofollow">http://localhost:8080</a></p>
  
  <p>Can someone explain how the second app runs locally when I did not specify 'localhost' in the http.listen() function? Also how do I point the second app to run from my IP address if the process is any different from the first?</p>