Connect to the database in an EC2 instance from the ECS cluster


I have Superset deployed on AWS using the guide where I chose to deploy it in an existing VPC. The Superset deployment worked out alright and I can access Superset at the provided link. When I try to connect to a database which is hosted in an EC2 instance, within the same VPC, I get the error, port 5432 is closed message on my Superset. The DB is up and running in the EC2 instance, which has been verified locally and remotely through my laptop.

I was previously able to connect to a database on RDS by adding the security group of the ECS Superset to the security group of the RDS instance. The same technique did not work for the ECS (Superset) -> EC2 (DB) connection. I also tried adding the IPv4 subnet range like 172...0/20 to the EC2 security group without success. These subnet ranges were obtained from the ECS deployment.

Any help to debug this issue would be greatly appreciated.

2 Answers
Accepted Answer

What worked for me finally was using the AWS endpoint public Ipv2 DNS - address of the EC2 instance instead of the public IP which I was trying to use before.

answered 2 years ago
  1. Check if MySQL DB is allowing all host IPs for given username.
  2. Use VPC Reachability Analyzer to check communication between network interfaces.
  3. Check ECS Service definition -> Security Groups -> EC2 DB Security group should be one of the value in this array.
profile pictureAWS
answered 2 years 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