APP in AWS ECS Fargate Can't Connect to Remote Database in Liquid Web.

0

Hi,

I have deployed a Nest.js application on AWS ECS Fargate, and am using a Network Load Balancer with two associated Elastic IPs, one for each subnet. Now, I am attempting to connect to our remote database on Liquid Web. I have already added both IPs to the WHM firewall whitelist settings, and have also added them to the Control Panel under Remote MySQL Hosts. I have checked the security group outbound rules and the network ACLs outbound rules, and everything seems to be in order. Could you please advise on what else I need to check?

Additionally, I have attempted to connect to this remote database via localhost using the same database URL string. After allowing my local public IP in the firewall and Remote MySQL Host, I was able to connect to the database.

Also I can connect to my app using the elastic IP address associated to the network load balancer after deployment.

I hope you can help me. :)

Thank you!

Reyver
asked 6 months ago255 views
1 Answer
1
Accepted Answer

Hello.

Do you mean connecting to the database from a container started on Fargate?
In that case, you need to allow the Fargate container IP address in the database.
NLB is only used to access the container, so the IP address used to access the database will be the Fargate IP address.
Additionally, the IP address of Fargate containers changes when tasks are swapped, etc., so you can use a fixed IP by starting the container in a private subnet and communicating via NAT Gateway.
https://repost.aws/knowledge-center/ecs-fargate-static-elastic-ip-address

To create a static IP address for a Fargate task for outbound traffic, create a NAT gateway. In this scenario, a static IP address is required by the downstream consumer. You must place your Fargate task on a private subnet. You can use the NAT gateway IP address for an IP allow list.

profile picture
EXPERT
answered 6 months ago
profile pictureAWS
EXPERT
reviewed 6 months ago
  • Thanks for this. I finally solve the problem. :D

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