0

I have an Amazon EC2 instance, Ubuntu. Here's my node example:

var express = require('express');
var app = express();
app.get('/', function(req, res){
  res.send('Hello Express');
});
app.listen(8080, 'http://ec2-xx-xx-xx-xx.us-west-x.compute.amazonaws.com');

The xx's are my actual address.

I start node in SSH, all is well.

I go to a browser on my laptop visit http://ec2-xx-xx-xx-xx.us-west-x.compute.amazonaws.com Node errors out (visiting same domain:8080 errors out too):

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: getaddrinfo ENOTFOUND
    at errnoException (dns.js:37:11)
    at Object.onanswer [as oncomplete] (dns.js:124:16)

I do have an inbound rule for HTTP on 80 setup on this instance.

3
  • Try this: app.listen(8080); Commented Mar 15, 2014 at 7:01
  • Now there's no error, node continues to listen, but browser just says couldn't connect to .... Commented Mar 15, 2014 at 7:04
  • Do you visit http://ec2-xx-xx-xx-xx.us-west-x.compute.amazonaws.com:8080? Commented Mar 15, 2014 at 7:17

2 Answers 2

1

You are listening on port 8080 but have inbound rule for port 80. Add a new rule on AWS EC2 console for port 8080.

Also, as suggested, just do app.listen(8080)

If you want the server to run on port 80, do app.listen(80). But you will have to run the process as super user. So sudo node app.js

Sign up to request clarification or add additional context in comments.

1 Comment

After correcting the other security group, I am doing app.listen(8080) instead now.
0

Thanks for trying, actually, I solved the problem.

I have two instances and they are in a different order than the order of my security groups for those instances...I setup a rule on port 80 for the other security group (the correct one) and it works now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.