notionquest
notionquest

Reputation: 39216

Curl the webpage hosted on the same EC2 instance not working

I have the web application hosted on EC2 instance and created the DNS for it. The web page works fine when I hit the URL in browser. However, when I curl the URL from EC2 instance, there is no response or rather getting connection error.

curl: (7) Failed connect to dnsurl.com:80; Operation now in progress

Also, in my web application, I am calling a servlet inside another servlet using Apache Post method. This is not working as well. The same code works fine on non-EC2 servers.

Not working:-

curl dnsurl.com
curl elburl.com

Working:-

Curl to other http urls are working fine from EC2 instance

curl http://www.w3schools.com/Tags/ref_urlencode.asp

Upvotes: 1

Views: 4372

Answers (2)

notionquest
notionquest

Reputation: 39216

Opening the ALB (Application Load Balancer) to allow inbound traffic from the EC2 instance on port 80 has resolved the issue.

Upvotes: 0

Sergey Kovalev
Sergey Kovalev

Reputation: 9411

Your URLs are resolved to the public IP addresses. So the request goes outside your EC2 instance. For that to work you need the following:

  1. Your security group should allow outbound traffic on port 80.
  2. Your network ACL should allow outbound traffic on port 80.

Upvotes: 3

Related Questions