fixes #6253 Host can not be removed

Fixed the issue and pushed the code for review, please check it.