aaP_hjintl Honestly, probably better to just use the loopback address and not rely on dns resolution at all, its a local resource so hitting it at 127.0.0.1 or ::1 should be exactly the same as what you are doing but without the additional DNS lookup call, also 'localhost' without the added TLD.
Here's a good example of the trap you'll run into:
ping localhost, it works right?
nslookup localhost, it doesn't work right? nxdomain...
If you can't ask the DNS resolver to resolve localhost, how can you ping it?
Suddenly you realize that resolving local domains depends on the mechanism used and how far abstracted the application is on from the low level system when resolving that address and not all of them play by the rules...
ping localhost.localdomain, does it work?
nslookup localhost.localdomain, do you get a nxdomain response again?
On a low /low/ level you can use localhost, but ultimately there's no good reason for local resources on the same system to address them via a fqdn, use the loop back address instead and see where you get?