fixed crash when hostname was invalid