Modifed getHostName to use the correct error code.

Review: https://reviews.apache.org/r/20055