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
已提問 7 個月前檢視次數 298 次
1 個回答
2
已接受的答案

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
專家
已回答 7 個月前
profile picture
專家
已審閱 1 個月前
profile pictureAWS
專家
已審閱 7 個月前
  • Thanks for this. I finally solve the problem. :D

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南