Fix NullPointerException if getHostByName failed