fixes #4527 Two errors in console when you try to add a host

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