fixes #3711 Error in console when I try to add a host manually

fixed the issue and committed code for review, please check it.