Cannot open EC2 instance public IPv4 address for Coursera AWS Cloud Technical Essentials Exercise 3

0

Hello I am working on the AWS Cloud Technical Essentials course on Coursera. While working through exercise 3, I ran into a problem.

Despite following all the steps as instructed when I attempt to open the Public IPv4 address for the EC2 instance (by copy-and-pasting it after http://) the webpage says "This page cannot be reached <Public IPv4 address> refuses to connect. ERR_CONNECTION_REFUSED" even though the instance is running, and has passed both status checks.

The security group has only one inbound security rule of type HTTP and source type ANYWHERE. When creating the instance the following code was placed in the User data box under advanced details:

#!/bin/bash -ex
wget https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/FlaskApp.zip
unzip FlaskApp.zip
cd FlaskApp/
yum -y install python3 mysql
pip3 install -r requirements.txt
amazon-linux-extras install epel
yum -y install stress
export PHOTOS_BUCKET=${SUB_PHOTOS_BUCKET}
export AWS_DEFAULT_REGION=<INSERT REGION HERE>
export DYNAMO_MODE=on
FLASK_APP=application.py /usr/local/bin/flask run --host=0.0.0.0 --port=80

With <INSERT REGION HERE> replaced with my region.
The instance also uses a key-pair with the .pem file downloaded onto my desktop.
Can anyone help me resolve this issue?

asked a year ago537 views
3 Answers
0

Hi,

In order to troubleshoot effectively I would suggest to login into your EC2 instance and try to check if your application is working by the running this command:

wget http://localhost

If your application is actually running you should get back an output line containing

HTTP request sent, awaiting response... 200 OK

If your application is running I would recommend to double check:

  • Security Group
  • Network ACL of your Subnets
AWS
answered a year ago
  • I am not sure how to run a command for an EC2 instance. Can you tell me how to do this?

  • To run the command on Ec2 instance you first need to connect to the instance by following one of the methods listed here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html Once you logged to your instance you can actually run the command by simply copy and paste this code "wget http://localhost"

  • Okay, I connected to my EC2 instance via ssh, and I ran the command you gave me through AWS CloudShell, and I got the following error

    Resolving localhost (localhost)... 127.0.0.1
    Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.
    

    What should be my next step?

  • Hi, here you can see that you application is not actually running, as you it is not reachable from you localhost. This exclude that the issue that you are facing is actually related to security group or other Ec2 network configurations. My suggestion now to keep troubleshooting is the following:

    • SSH to your instance
    • Manually execute the script that is supposed to start your application and then double check again if your application is running
    • If your application is not running the issue is within the script
  • Did this help? can you please consider to accept my answer?

0

Hi, Looks like i faced with same problem. Have you solved it?

Kuskov
answered a year ago
0

I am unable to get this exercise to work. I have ssh'd to the ec2 instance and notice that when I enter the following command:

$ wget https://aws-tc-largeobjects.s3-eu-north-1.amazonaws.com/DEV-AWS-MO-GCNv2/FlaskApp.zip

I get the response:

-bash: wget https://aws-tc-largeobjects.s3-eu-north-1.amazonaws.com/DEV-AWS-MO-GCNv2/FlaskApp.zip: No such file or directory

Is this why the example doesn't work?

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions