Can't get connected with rds

When I connect to mysql installed on local instance it is working fine. I’m not able to connect with rds using the endpoint provided by AWS but we can connect using the ip address obtained from ping. It would be great if any let me know how to connect with RDS using endpoint. I’ve tried with ODBC driver and it gets connected as well.

Error: res_config_mysql. mysql_reconnect: Mysql Realtime: Failed to connect to database