How to debug or fix Connection Refused trying to curl EC2 instance port?

Viewed 460

I've created an EC2 instance, but I seem unable to reach a service I've launched on it (say on port 1234). The instance is

  • part of a permissive security group with all traffic from anywhere allowed (I know this is not advisable, but it's just to get this working)
  • in a public subnet of a VPC

I've launched an httpd server on the instance and verified I can reach it on port 80 from either my machine or another EC2 instance in the same subnet. I've also verified that I can curl localhost:1234 from the original EC2 instance.

But I get Failed to connect to $MY_IP port 1234: Connection refused whenever I try to curl the port from my machine or the other EC2 instance in the same subnet (trying both private and public IP). What could still be blocking the request? How can I start to debug?

I've already looked through answers like these, but my security group should already allow this traffic. security group detail

1 Answers

Based on the comments.

The issue was caused by binding application to localhost, which makes it only accessible from within the instance. Changing the binding to 0.0.0.0 solved the problem.

Related