Unable to connect with public postgresql rds instance : Connection Timed out

amazon-rdsamazon-web-servicesnetworkingpostgresql-9.3

I created a basic test PostgreSQL RDS instance in a VPC. It is public and VPC security group. The security group whose configuration is as follows:
Inbound Rule:
Type: PostgreSQL
Protocol: TCP
Port:5432
Source: 0.0.0.0/0
Outbound:
Type: All
Protocol: All
Port: All
Destination: 0.0.0.0/0

When I try to connect, it fails. Here's the error code that I get:
could not connect to server: Connection timed out
Is the server running on host () and accepting
TCP/IP connections on port 5432?

I m doing this for the first time so please help me out. Any help will be appreciated.

Best Answer

I'm a bit late, but for those looking on in the future:

I encountered this error and looked up every possible solution: VPC connection, security groups, changing my pg_hba.conf and postgresql.conf files, making sure my program was publicly accessible, etc.

My problem was that I was using Python 3.7 as my runtime on AWS lambda, and Pyton 3.8 uploaded into S3 bucket dependencies! It took me way too long to figure this out. Live and learn, I guess!