Podman Mongo db Replication - host dns getting resolved to


I am trying to setup a replication for mongo db, by running each node (containerized) on different hosts/machines. When trying to setup replica set using the rs.initiate command

rs.initiate({ _id: "rs1", version: 1, members: [ { _id: 0, host: 'container-host-dns:15017' }]})

where container-host-dns is the host dns where mongo db container runs and 15017 is the port mapped to the mongo db default port. When I run the rs.initiate command, I get an error and on the logs I find the following:

SocketException: Error connecting to container-host-dns:15017 ( :: caused by :: syncConnect connect error :: caused by :: Connection refused"}}}

It looks like mongodb resolves the dns container-host-dns to, my container /etc/hosts looks like for container-host-dns: container-host-dns.something.com container-host-dns
::1 container-host-dns.something.com container-host-dns

I am not good with networking stuff, any help/suggestion on how to resolve this issue is much appreciated!

P.S: If I use the ip insteadof dns container-host-dns within the rs.initiate command, then it works fine.