It is not a problem of your application. Possible reasons are that there is no DNS server for the network to which the IP belongs, there is a DNS server but that has no record for that IP, or the IP belongs to a different local subnet than the local subnet of your system.
You can check it on the command line with the
nslookup utility:
nslookup ip-address
If that fails too, you can't do anything in your application besides catching this error and returning for example the IP address instead (catching errors is always a good idea; especially with operations that may fail for various reasons like network).
If there is a local DNS server but it does not have a record for that IP, you might also ask the administrator of that server.