EC2 instances won't respond when accessed by IPv4

0

I have been creating simple EC2 instances, which include code to draw content from a DynamoDB database. At first they can be accessed normally by entering their IP address into a browser, but once the database is implemented any attempt to access them results in a "refused to connect" error. This persists after the database instance is deleted. What do I do? Below is the user data script for the EC2 instances:

#!/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-pip pip install -r requirements.txt 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

MaxB
asked a year ago193 views
1 Answer
0

It seems to be connection issue and firewall might be blocking it. Can you please make sure of following:

  1. Network access control list (network ACL) associated with the instance's subnet has rules allowing both outbound and inbound traffic to the internet.
  2. Route table that's associated with your instance’s subnet has a default route to an internet gateway (0.0.0.0/0).
  3. Internet gateway exists and is associated with the route
  4. Security group attached to the instance’s elastic network interface has rules allowing outbound internet traffic (0.0.0.0/0) for required ports and protocols. Also make sure, inbound rule of the security group allows traffic for required protocl and ports

Also make sure, if the instance is in a public subnet then it has public ip address, as otherwise it won't be accessible outside the virtual private cloud (VPC) in which it resides.

If none of this helps, then please go through this re:Post Knowledge Center Article, this would certainly help you.

Hope you find this useful.

Abhishek

profile pictureAWS
EXPERT
answered a year ago
  • Do you have additional questions, happy to help.

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