{"id":445,"date":"2020-01-23T10:22:00","date_gmt":"2020-01-23T10:22:00","guid":{"rendered":"https:\/\/www.smarthost.eu\/blog\/?p=445"},"modified":"2022-08-30T06:42:18","modified_gmt":"2022-08-30T06:42:18","slug":"modifying-the-hosts-file","status":"publish","type":"post","link":"https:\/\/www.smarthost.au\/blog\/modifying-the-hosts-file","title":{"rendered":"Modifying the hosts file"},"content":{"rendered":"\n<p>The hosts file allows you to overwrite the domain&#8217;s DNS for a specific machine (computer, server, etc.). This option is helpful when you are migrating data between servers. Before changing the DNS of the domain on which the moved page is available, you can modify the hosts file to see if it works correctly from the new server.<br>Entries in the file are taken into account before DNS queries. This means that due to changes in the hosts file, you can get a reference directly to any server without querying DNS servers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to modify the hosts file?<\/h2>\n\n\n\n<p>This article describes how to modify the file on the following systems:<br>&#8211; Linux<br>&#8211; MacOS X<br>&#8211; Microsoft Windows 10, Windows 8, Windows 7, Windows Vista<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Linux and MacOS X<\/h2>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Open a terminal<br>&nbsp;&nbsp;&nbsp;&nbsp;Type the following command to open the hosts file in a text editor:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;sudo nano \/ etc \/ hosts<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Enter the password required to log in as an administrator.<br>&nbsp;&nbsp;&nbsp;&nbsp;Make the necessary changes to the file.<br>&nbsp;&nbsp;&nbsp;&nbsp;Use Ctrl + O and then Enter to save the changes.<br>&nbsp;&nbsp;&nbsp;&nbsp;Press Ctrl + X to exit the editor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"491\" height=\"107\" src=\"https:\/\/www.smarthost.eu\/blog\/wp-content\/uploads\/2020\/01\/Zrzut-ekranu-z-2020-01-09-15-56-33.png\" alt=\"\" class=\"wp-image-446\" srcset=\"https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2020\/01\/Zrzut-ekranu-z-2020-01-09-15-56-33.png 491w, https:\/\/www.smarthost.au\/blog\/wp-content\/uploads\/2020\/01\/Zrzut-ekranu-z-2020-01-09-15-56-33-300x65.png 300w\" sizes=\"auto, (max-width: 491px) 100vw, 491px\" \/><figcaption><strong>The entry should look like this<\/strong><br> (Server IP followed by the website&#8217;s domain name, preferably with www and without www)<\/figcaption><\/figure><\/div>\n\n\n<p>Windows 10 and Windows 8<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Press the Windows key to display the Start Menu<\/li><li>Enter &#8220;Notebook&#8221; and find the editor in the search results<\/li><li>Right click on Notebook and select &#8220;Run as Administrator&#8221;<\/li><li>Open the C: \\ Windows \\ System32 \\ Drivers \\ etc \\ hosts file<\/li><li>Make changes and save the file<\/li><\/ol>\n\n\n\n<p>Please note that if the page was already opened before the change, you should clear the browser cache or open the page in another browser, alternatively using a different network (cache can also be stored at the router level).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The hosts file allows you to overwrite the domain&#8217;s DNS for a specific machine (computer, server, etc.). This option is helpful when you are migrating data between servers. Before changing the DNS of the domain<a class=\"read-more\" href=\"https:\/\/www.smarthost.au\/blog\/modifying-the-hosts-file\">Continue reading<\/a><\/p>\n","protected":false},"author":16,"featured_media":459,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,19,20,177],"tags":[],"class_list":["post-445","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dns","category-domain","category-hosting","category-important"],"_links":{"self":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts\/445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":4,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":4819,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions\/4819"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/media\/459"}],"wp:attachment":[{"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.smarthost.au\/blog\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}