Fix bug when a invalid hostname is stored in the database