0

I have an ubuntu 14.04 server I PuTTy into, and I am just trying to learn and set up node. I have tried to follow several tutorials, but most deal with localhost, which is not applicable to me so I get stuck. I have created Hello.js, and it looks like this:

var http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end('Hello Http');
});
server.listen(8080);

When it starts I can't access it in the browser, but if I include say "console.log()" then stuff displays in the terminal, but always a 404 in the browser.. ideas?

1 Answers1

0

Figured it out, the issue I was having was it was defaulting to 172.0.0.1 or something, needed to add optional param of 0.0.0.0 into listen call! thanks

  • Yeah, this is because `127.0.0.1` is only the local loopback device and does not bind to external incoming requests by default. See my answer on a similiar question here: http://stackoverflow.com/a/17588984/1993402 – ConcurrentHashMap Sep 11 '14 at 13:31