Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS instance connection refused

I have created amazon EC2 instance and able to SSH also using below command

ssh -i Ec2CHD5.pem [email protected]

When I try to ping c2-xx-xx-xxx-xxx.ap-southeast-1.compute.amazonaws.com I am able to do so also.

But when try to curl curl http://c2-xx-xx-xxx-xxx.ap-southeast-1.compute.amazonaws.com I am getting connection refused, am I missing any step or guidelines?

Could somebody guide me to troubleshoot.

like image 238
Divya Avatar asked Sep 13 '25 22:09

Divya


2 Answers

Probably your server running on the aws instance is only listening to localhost or 127.0.0.1, thus it will ignore connections from the outside. try listening to 0.0.0.0

like image 99
terix2k11 Avatar answered Sep 16 '25 13:09

terix2k11


In my case the problem was not in aws, but in the http service I started. My http service was a node express app. In the listen command I had to pass '0.0.0.0' as the listening server, NOT '127.0.0.1'

http.createServer( .... ).listen(80, '0.0.0.0');

On aws side, this is the usual checklist :

  1. public ip address enabled for your instance
  2. security group should have proper inbound rules
  3. subnet associated to your instance, should have proper Network ACL & Route table.

For these three steps on aws side, you can refer this page : https://aws.amazon.com/premiumsupport/knowledge-center/instance-vpc-troubleshoot/

like image 36
ramu Avatar answered Sep 16 '25 11:09

ramu