PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 20, 2022

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

 April 20, 2022     amazon-ec2, amazon-web-services, connection     No comments   

Issue

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


Solution

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.



Answered By - Marcin
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing