Scott
Scott

Reputation: 827

Serve node Webapp on port 80 in amazon ec2

I have a node application listening on port 80, I have set the security groups open on port 80. enter image description here

But, when I access my webapp in browser via public ip(http://xx.xxx.xx.xxx/), it doesn't show up.

What could be the issue?

I've use this doc as a guide https://aws.amazon.com/premiumsupport/knowledge-center/connect-http-https-ec2/

Upvotes: 1

Views: 1522

Answers (2)

Scott
Scott

Reputation: 827

So The answer was, my security groups were fine. My app wasn't running because I didn't set the environment variable correctly. sudo PORT=80 node server.js was the command I needed.

Upvotes: 0

Adiii
Adiii

Reputation: 60144

When your security group already allowed traffic It means something wrong with the instance.

The first step to debug such an issue to verify the application status inside the instance.

  • do ssh to the instance and verify is the instance responding on localhost curl localhost
  • check is the process running, if you are using any nodejs process manager like pm2 pm2 list or forever forever list or ps -aux | grep node
  • Verify is the server running on port 80.
  • check is the port occupied netstat -antu | grep LISTEN

In short, if the application responding on localhost using curl localhost, then as mentioned in the comment then the instance is in the private subnet.

you can check this article to know about public and private subnet.

Upvotes: 2

Related Questions