Properly handle hostnames as well as IPs