Postgres node issue

Hi All,

I have an issue described as below.
I have a node-red installed on AWS EC2.
I have PostgreSQL database on AWS RDS.
Now, I'm trying to add postgres node to insert the data to the postgres. but I faced several issues.
When I set an EC2 connection on the RDS I can access the database from SSH only and got this error in node-red

"error: no pg_hba.conf entry for host "x.x.x.x", user "postgres", database "postgres", no encryption"

And then I changes the inbound and outbound rules in both EC2 and RDS to connect to the specific IP and I got the following error from both SSH and node-red

error: connection timeout

What is the problem and how to fix it? I spent four days on it without any solution.