Kubernetes supports DNS SRV (service) records for named ports
For each named port the record in following format is created:* _portname._protocol.service.namespace.svc.cluster.local*
There is service:mongodb in namespace:default with protocol:tcp and portname:mongodb
The service endpoint is statefulset:mongodb with instances mongodb-[0...9]
For each of the instances the following resource record is created
_mongodb._tcp.mongodb.default.svc.cluster.local service = 10 100 27017 mongodb-N.mongodb.default.svc.cluster.local. <-- A record that resolves to the IP of the instance itself.
As we can see the host resides in the service subdomain and the software throws an error.
Besides that it doesnt allow to connect to top-level domain resources requiring the address url must have at least 3 hostname components separated by dots ('.')