4

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

ssh -i Ec2CHD5.pem ubuntu@ec2-xx-xx-xxx-xxx.ap-southeast-1.compute.amazonaws.com

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.

Scott
  • 6,089
  • 4
  • 34
  • 51
Divya
  • 95
  • 1
  • 9

3 Answers3

4

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

terix2k11
  • 342
  • 1
  • 4
  • 15
2

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/

ramu
  • 1,415
  • 1
  • 13
  • 12
1

You will need to configure the security group of your EC2 instance and allow the http traffic to go through.

You can do it at the AWS management console. Browse to the EC2 section where you can see all your instances. Right click on the instance(whose security group you wish to change) and select Networking > Change Security Groups

Check the security groups you wish to assign and click the Assign Security Groups button.

You can also create a security group(if there is not one) that allows inbound http traffic.

Noman Ur Rehman
  • 6,707
  • 3
  • 24
  • 39
  • 1
    I have configured security groups also and added all TCP ports also from anywhere .Do I need to mention for http also? I have one more confusion If I create an instance in EC2 and configure it for all TCP ports for anywhere and then If I do curl should it listen to default port if I dont mention specfic port number .For instance if I try to do http://http://c2-xx-xx-xxx-xxx.ap-southeast-1.compute.amazonaws.com should it display the page in browser? – Divya Jun 08 '15 at 02:47
  • I have been having this issue for days. Cannot figure out what's happening. I have added all the necessary TCP rules. I have also added outbound just in case. But nothing works. – Adarsh Khatri Aug 24 '20 at 00:04