{"id":82,"date":"2019-05-31T10:19:37","date_gmt":"2019-05-31T10:19:37","guid":{"rendered":"https:\/\/www.eurovps.com\/faq\/?post_type=ht_kb&#038;p=82"},"modified":"2019-05-31T10:19:37","modified_gmt":"2019-05-31T10:19:37","slug":"how-to-edit-hosts-files-in-windows-mac-linux","status":"publish","type":"ht_kb","link":"https:\/\/www.eurovps.com\/faq\/how-to-edit-hosts-files-in-windows-mac-linux\/","title":{"rendered":"How to edit hosts files in Windows, Mac, Linux"},"content":{"rendered":"\n<p>Hosts file entries used to resolve hosts names before DNS. Adding host entries to your local PC &#8216;s hosts file which will allow you to see the domain hosted from the server IP that you added in the hosts file.<\/p>\n\n\n\n<p>Modifying your hosts file will allow you to override the DNS for a domain, on that particular machine. This can be used to test your site without changing the DNS. If you add host entry, machine only to look directly at the IP specified in the host file.<\/p>\n\n\n\n<p>Your hosts file will need to have two entries added that will contain the IP address you want the site to resolve to and the address.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">IP domain.com <a href=\"http:\/\/www.domain.com\/\">www.domain.com<\/a><\/pre>\n\n\n\n<p>Example<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">77.235.XX.XX domain.com <a href=\"http:\/\/www.domain.com\/\">www.domain.com<\/a><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Windows OS<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">C:\\WINDOWS\\system32\\drivers\\etc\\hosts<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Go to Start &gt; run Notepad.&nbsp;<\/li><li>Right click on the Notepad icon and select &#8220;Run as&nbsp;administrator.&#8221;<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.eurovps.com\/images\/uploads\/administrator-hosts.png\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Select Open from the File menu option.&nbsp;<\/li><li>In the File name field, enter the following path:&nbsp;<strong>c:\\Windows\\System32\\drivers\\etc\\hosts<\/strong><\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.eurovps.com\/images\/uploads\/notepad-hosts.png\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Add the&nbsp;<strong>hostname\/domain name<\/strong>&nbsp;and&nbsp;<strong>IP<\/strong>&nbsp;address to the bottom of the host file.<\/li><\/ul>\n\n\n\n<p><strong>For example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">77.235.XX.XX  example.com <a href=\"http:\/\/www.example.com\/\">www.example.com<\/a><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.eurovps.com\/images\/uploads\/windows-hosts-file-edit.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Once the proper domain information is added you will save the file and your system will begin resolving to the specified IP.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Linux Operating Systems<\/h2>\n\n\n\n<p>Hosts file location :&nbsp;<strong>\/etc\/hosts<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Open a Terminal window.&nbsp;<\/li><li>Open the hosts file in a text editor &#8211; you can use vi command or a different one you have available to open up the hosts file<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/hosts<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Add the destination server&#8217;s IP address and domain name under the latest entry in the file.<\/li><\/ul>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">77.235.XX.XX  example.com <a href=\"http:\/\/www.example.com\/\">www.example.com<\/a><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Save the host file.&nbsp;<\/li><li>Reload your browser for the changes to take effect.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">MacOS X<\/h2>\n\n\n\n<p>Hosts file location :<strong>&nbsp;\/private\/etc\/hosts<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Open a Finder window.&nbsp;<\/li><li>Select Applications from the sidebar.&nbsp;<\/li><li>Double-click on Utilities.<\/li><li>Double-click Terminal.&nbsp;<\/li><li>Type sudo nano \/etc\/hosts<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo nano \/etc\/hosts<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Enter your administrator password&nbsp;<\/li><li>Add hosts entry with your server IP and domain name.<\/li><\/ul>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">77.235.XX.XX  example.com <a href=\"http:\/\/www.example.com\/\">www.example.com<\/a><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Once you&#8217;re done, hold down the&nbsp;<strong>control<\/strong>&nbsp;and&nbsp;<strong>O<\/strong>&nbsp;keys to save the file, then&nbsp;<strong>control<\/strong>&nbsp;and&nbsp;<strong>X<\/strong>&nbsp;to exit.<\/li><\/ul>\n\n\n\n<p>Note: You need to run a ping test to ensure that it shows the correct IP. Once testing is finished these entries should be removed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hosts file entries used to resolve hosts names before DNS. Adding host entries to your local PC &#8216;s hosts file which will allow you to see the domain hosted from the server IP that you added in the hosts file. Modifying your hosts file will allow you to override the&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[17],"ht-kb-tag":[],"class_list":["post-82","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-how-to"],"_links":{"self":[{"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/ht-kb\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":1,"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/ht-kb\/82\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/ht-kb\/82\/revisions\/83"}],"wp:attachment":[{"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/ht-kb-category?post=82"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.eurovps.com\/faq\/wp-json\/wp\/v2\/ht-kb-tag?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}