{"id":78,"date":"2012-07-09T15:37:11","date_gmt":"2012-07-09T15:37:11","guid":{"rendered":"http:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=78"},"modified":"2025-04-16T12:00:45","modified_gmt":"2025-04-16T11:00:45","slug":"how-to-use-hosts-file","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/","title":{"rendered":"How To Edit The Hosts File In Windows, Linux, and macOS Operating Systems?"},"content":{"rendered":"\n<p>The hosts file is used to map domain hostnames to IP addresses. Using the hosts file you can point any domain name OR hostname to the desired IP on your local machine.<\/p>\n\n\n\n<p>The hosts file is a massive help when an individual\/webmaster\/developer wants to test website design or code on domains that are not registered OR do not point to the desired server IP. Don\u2019t need to wait for DNS to propagate when pointed to a different web server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps To Add New Entries To The Windows Host File<\/h2>\n\n\n\n<p>Follow these steps to add new entries in the host file for the Windows operating system:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on the <strong>Start<\/strong> button and type<strong> notepad.<\/strong><\/li>\n\n\n\n<li>Right-click on <strong>Notepad<\/strong> and select the option <strong>\u201cRun as administrator\u201d<\/strong> to open Notepad.<\/li>\n\n\n\n<li>Now, go to <strong>File <\/strong>and click on <strong>Open<\/strong>.<\/li>\n\n\n\n<li>Click on <strong>This PC<\/strong>.<\/li>\n\n\n\n<li>Select Local Disk&nbsp; <strong>C drive<\/strong><\/li>\n\n\n\n<li>Go to the <strong>Windows <\/strong>folder.<\/li>\n\n\n\n<li>Click on the System32 folder.<\/li>\n\n\n\n<li>Choose the drivers folder.<\/li>\n\n\n\n<li>Now, select the <strong>etc <\/strong>folder.<\/li>\n\n\n\n<li>As you\u2019ll see, no files are showing in this folder.<\/li>\n\n\n\n<li>To change the view from <strong>text document to all files<\/strong>, simply navigate to this drop-down and select the <strong>all files<\/strong> option.<\/li>\n\n\n\n<li>Select the <strong>hosts <\/strong>file and click on <strong>Open.<\/strong><\/li>\n\n\n\n<li>In the same file, enter the <strong>IP address<\/strong> and <strong>domain name as per your choice.<\/strong><\/li>\n\n\n\n<li>You can use the external IP address provided by your new hosting provider if you wish to test how your website is loading on that IP address before updating its DNS of your website.<\/li>\n\n\n\n<li>Here, we have entered the <strong>localhost IP address, i.e., 127.0.0.1,<\/strong> and <strong>www.milesweb.com<\/strong>&nbsp; as a <strong>domain name<\/strong>.<\/li>\n\n\n\n<li>Navigate to <strong>File <\/strong>and click on <strong>Save <\/strong>to save the file.<\/li>\n\n\n\n<li>Now close this window.<\/li>\n\n\n\n<li>To test this hosts file, again go to the <strong>Search Box<\/strong>, type <strong>cmd, <\/strong>and hit enter.<\/li>\n\n\n\n<li>The command prompt window appears on the screen.<\/li>\n\n\n\n<li>Type the command <strong>ping <\/strong>space website name,<strong> i.e., www.milesweb.com <\/strong>in our case, and<strong> press enter.<\/strong><\/li>\n\n\n\n<li>Now you can see <strong>milesweb <\/strong>resolving to <strong>the localhost IP address<\/strong> rather than <strong>MilesWeb\u2019s external IP address.&nbsp;&nbsp;<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Steps To Add New Entries To The Linux Host File<\/h2>\n\n\n\n<p>Follow these steps to add new entries in the host file for the Linux operating system:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To open the terminal on ubuntu press the shortcut keys <strong>Ctrl + ALT + T <\/strong>simultaneously<strong>.<\/strong><\/li>\n\n\n\n<li>In the terminal window, type the below command and press enter.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo nano \/etc\/hosts&nbsp;<\/em><\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Type the password of your PC.<\/li>\n\n\n\n<li>The file will directly get opened.<\/li>\n\n\n\n<li>Enter the <strong>IP address<\/strong> and <strong>domain name as per your choice.<\/strong><\/li>\n\n\n\n<li>Here, we have entered <strong>the localhost IP address, i.e., 127.0.0.1,<\/strong> and <strong>www.milesweb.com<\/strong>&nbsp; as <strong>a domain name<\/strong>.<\/li>\n\n\n\n<li>Press <strong>CTRL + X<\/strong> simultaneously to save this file.<\/li>\n\n\n\n<li>It will ask for the confirmation; in that, <strong>press y and hit enter<\/strong>.<\/li>\n\n\n\n<li>Now, type this command: <strong>ping space website name and press enter<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p>As you can see, <strong>milesweb is<\/strong> resolving to <strong>the localhost IP address<\/strong> rather than <strong>MilesWeb\u2019s external IP address.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps To Add New Entries To The Mac Host File<\/h2>\n\n\n\n<p><strong>Follow these steps to add new entries in the host file for Mac users (Apple macOS):<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Open the Terminal<\/strong><\/li>\n<\/ul>\n\n\n\n<p>To open the Terminal, press Command (\u2318) (Command key symbol) + Space and use Search for Finder.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Open the Hosts File<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Now, input the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo nano \/etc\/hosts<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>When prompted, provide your Mac password.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Edit the Hosts File<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Look for the arrow keys to navigate to the bottom of the file. Add the following entry:<\/p>\n\n\n\n<p><strong><em>123.123.123.123 example.com<\/em><\/strong><\/p>\n\n\n\n<p>(Make sure to replace 123.123.123.123 with the actual server IP and example.com with your domain.)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Save and Exit<\/strong><\/li>\n<\/ul>\n\n\n\n<p>In the step before this, you pressed Control + X.<\/p>\n\n\n\n<p>Now, you have to press Y and then press Enter to save.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Flush DNS Cache<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Run the command below to apply changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><em>sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>There are no explicit messages; the changes will be effective immediately.<\/p>\n\n\n\n<p>That\u2019s how you can edit the hosts file in the Windows, Linux, and macOS operating systems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The hosts file is used to map domain hostnames to IP addresses. Using the hosts file you can point any domain name OR hostname to the desired IP on your local machine. The hosts file is a massive help when an individual\/webmaster\/developer wants to test website design or code on domains that are not registered [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7],"class_list":["post-78","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-domain-name-dns-issues","tag-hosts-file"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to edit hosts file in Windows and Linux operating system?<\/title>\n<meta name=\"description\" content=\"Discover how to use the hosts file to access websites using custom domain mappings. Take control of your browsing experience with host file management!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to edit hosts file in Windows and Linux operating system?\" \/>\n<meta property=\"og:description\" content=\"Discover how to use the hosts file to access websites using custom domain mappings. Take control of your browsing experience with host file management!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-09T15:37:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-16T11:00:45+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/\",\"name\":\"How to edit hosts file in Windows and Linux operating system?\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"datePublished\":\"2012-07-09T15:37:11+00:00\",\"dateModified\":\"2025-04-16T11:00:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/90143c7d8df4b4de36b3dbb0bb272f69\"},\"description\":\"Discover how to use the hosts file to access websites using custom domain mappings. Take control of your browsing experience with host file management!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Edit The Hosts File In Windows, Linux, and macOS Operating Systems?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/90143c7d8df4b4de36b3dbb0bb272f69\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/42e5b55cc2772cd685c8803f6f7f854b?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/42e5b55cc2772cd685c8803f6f7f854b?s=96&d=blank&r=g\",\"caption\":\"admin\"},\"description\":\"With over 10+ years of experience in the web hosting industry, I have achieved extensive exposure to result-oriented methodologies. And expertise in different domains like Datacentre Services, Cloud computing technology, Web hosting industry and many more.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to edit hosts file in Windows and Linux operating system?","description":"Discover how to use the hosts file to access websites using custom domain mappings. Take control of your browsing experience with host file management!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/","og_locale":"en_GB","og_type":"article","og_title":"How to edit hosts file in Windows and Linux operating system?","og_description":"Discover how to use the hosts file to access websites using custom domain mappings. Take control of your browsing experience with host file management!","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2012-07-09T15:37:11+00:00","article_modified_time":"2025-04-16T11:00:45+00:00","author":"admin","twitter_misc":{"Written by":"admin","Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/","name":"How to edit hosts file in Windows and Linux operating system?","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"datePublished":"2012-07-09T15:37:11+00:00","dateModified":"2025-04-16T11:00:45+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/90143c7d8df4b4de36b3dbb0bb272f69"},"description":"Discover how to use the hosts file to access websites using custom domain mappings. Take control of your browsing experience with host file management!","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-use-hosts-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How To Edit The Hosts File In Windows, Linux, and macOS Operating Systems?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/90143c7d8df4b4de36b3dbb0bb272f69","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/42e5b55cc2772cd685c8803f6f7f854b?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/42e5b55cc2772cd685c8803f6f7f854b?s=96&d=blank&r=g","caption":"admin"},"description":"With over 10+ years of experience in the web hosting industry, I have achieved extensive exposure to result-oriented methodologies. And expertise in different domains like Datacentre Services, Cloud computing technology, Web hosting industry and many more.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/admin\/"}]}},"views":1541,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":12,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":16720,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/78\/revisions\/16720"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}