fixes #5964 errors in console when copying host

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