fixes #5131 Error in console copying host

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