Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the public URL of my EC2 instance?

Some sources suggest that it's https://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/ (where xxx-xxx-xxx-xxx is the public IP address of the machine). But when I navigate there Chrome says This site can’t be reached.

like image 619
rafaelcosman Avatar asked Mar 20 '16 19:03

rafaelcosman


People also ask

How do I find my EC2 URL?

Use the following command to access the public IP address: IMDSv2. [ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \ && curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/public-ipv4.

How do I find my EC2 instance details?

You can use EC2 Instance Metadata Query Tool which is a simple bash script that uses curl to query the EC2 instance Metadata from within a running EC2 instance as mentioned in documentation. now run command to get required data.


2 Answers

Just use host command and specify your public IP - it will show you the right URL, e.g.

$ host 52.204.122.132
132.122.204.52.in-addr.arpa domain name pointer ec2-52-204-122-132.compute-1.amazonaws.com.

where ec2-52-204-122-132.compute-1.amazonaws.com is your domain.

So you can add https:// in front of it to access the instance via HTTPS.

like image 115
kenorb Avatar answered Oct 04 '22 15:10

kenorb


When you access an URL from any browser, you need to make sure there is a server running on port 80, that is the default port. If you just launched a Linux ec2 instance, it's only accessible through ssh. To access these instances you need de access certificate, generated during the launch process and a ssh client, like ssh for Linux or putty for Windows. Also, if you do have a service running on port 80 or any other, you should make sure these ports are opened in the security policy of your instance.

like image 35
ThiagoSckianta Avatar answered Oct 04 '22 17:10

ThiagoSckianta