简体   繁体   中英

Using node.js on AWS ec2 t1.micro?

I'm attempting the "Hello World" node.js script but I'm running into a hiccup....I'm executing the program but it's not connecting to my localhost:8080 because right after I execute the program when I go to my browser, I'm getting a Chrome "Oops Google cannot find" page. I am running from a AWS t1.micro ec2 instance in Cygwin on Windows so I'm not sure if its a CPU problem but I'm puzzled as to what's happening and I don't want to move forward without understanding why.

  var http = require("http"); //How we require modules

  http.createServer(function(request, response) {
    response.writeHead(200); //Status code in header
    response.write("Hello World!"); //Response body
    response.end(); // close the connection
  }).listen(8080);

 console.log('Listening on port 8080...');

Does your chrome also run on the same t1.micro? Otherwise you need to use the IP-adress/domain name of the instance.

Make sure your Security Group allow port 8080 to be reached from your local machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM