Connect to remote EC2 Postgresql database
You need to work your way up the networking stack to determine where the issue is.

Can you ping the destination from the source?

Can you telnet to the postgres port(5432 by default) from the source? 

Can you connect to the postgres service with a management tool(pgadmin or psql) from the source?