Mongodb connecting issue

my mongo db and node application gets connected only if inbound rules open for mongo db port if not it is not getting connected what could be the possible issue…
My application is hosted in aws with both application and db in docker