2

I am using a ec2 server running ubuntu and nodejs. I thought this would create a valid server that would respond if I went to my ec2 web address.

var http = require("http");
var port = 80; 
var serverUrl = "0.0.0.0";
console.log("Starting web server at " + serverUrl + ":" + port); http.createServer(      
function(req, res) {
  timestamp = new Date();
  console.log("Request for URL " + req.url + " received at " + timestamp);
  if (req.url === '/error') {
    console.log('Throwing an error');
    throw "Oops";
  }
  res.end("Hello World " + timestamp);
}).listen(port, serverUrl);

I have used nodejs and espesially express for a while but never have tried to deploy it myself on a vps, any advice is appreciated.

Daniel
  • 35,039
  • 9
  • 83
  • 70
joshua-anderson
  • 4,278
  • 5
  • 29
  • 54
  • 1
    [Did you open port 80 for incoming traffic in the security group administration?](http://stackoverflow.com/a/10454688/477878) (or whatever it's called nowadays :) – Joachim Isaksson May 24 '13 at 04:28
  • Is it just me or are all the node.js questions today actually system administration questions? There's serverfault for that. – PP. May 24 '13 at 08:53

1 Answers1

8

Make sure you have port 80 open on the EC2 Security Group.

Test that it's answering on port 80 by by using curl from the machine's command line.

curl -v http://localhost/

If it's answering via a local curl, you probably just have a firewall issue.

Daniel
  • 35,039
  • 9
  • 83
  • 70
  • Thanks, I have the same issue. But tests prove it to be fine - 'connected [...] Accept: */*', though the app seems to hang on 0.0.0.0 – Alex Buznik Aug 28 '13 at 17:00