{"id":547,"date":"2016-06-01T00:00:00","date_gmt":"2016-06-01T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/dnshow-to-emulate-edit-windows-hosts-file\/"},"modified":"2024-12-16T08:33:36","modified_gmt":"2024-12-16T08:33:36","slug":"how-to-edit-hosts-file","status":"publish","type":"post","link":"\/tutorials\/how-to-edit-hosts-file","title":{"rendered":"How to edit hosts file in Windows, macOS and Linux"},"content":{"rendered":"<p>Your computer&rsquo;s hosts file maps a domain name to its IP address. If you experience an unreachable web page or want to block a specific website, editing the hosts file can be the solution.<\/p><p>In this article, you will learn how to edit the hosts file in Windows, macOS, and Linux. Before getting into the steps, we&rsquo;ll explain what a hosts file is exactly so you understand why learning to modify it can be a useful skill.<\/p><p>\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-a-hosts-file\">What is a hosts file<\/h2><p>A <strong>hosts <\/strong>file is a configuration in your operating system that maps a domain name to its corresponding internet protocol (IP) address.<\/p><p>It works similarly to a <a href=\"\/tutorials\/what-is-dns\">domain name system<\/a> (DNS) server, which translates a website&rsquo;s domain into its IP address so your web browser can access it.<\/p><p>The difference is that your operating system will prioritize the host file over the DNS server. If information about the corresponding IP address is unavailable locally, your internet service provider will use the DNS server.<\/p><p>Editing the hosts file means manually adding a domain or <a href=\"https:\/\/www.lenovo.com\/sg\/en\/glossary\/hostname\/\" target=\"_blank\" rel=\"noreferrer noopener\">hostname<\/a> and its IP address. It can be helpful in several scenarios:<\/p><ul class=\"wp-block-list\">\n<li><strong>Resolving domains<\/strong> &ndash; when hosting a website, editing the hosts file allows your domain to become accessible immediately without waiting for <a href=\"https:\/\/support.hostinger.com\/en\/articles\/4146975-what-is-dns-propagation\" target=\"_blank\" rel=\"noopener\">DNS propagation<\/a>. This is useful if you want to check the site quickly.<\/li>\n\n\n\n<li><strong>Connecting hostnames<\/strong> &ndash; DNS servers often can&rsquo;t resolve a hostname to its IP address. Modifying the hosts file enables you to explicitly specify the address.<\/li>\n\n\n\n<li><strong>Blocking websites<\/strong> &ndash; for organizations or parents, editing the hosts file lets you block access to a specific website by assigning a custom IP address to its domain.<\/li>\n\n\n\n<li><strong>Fixing errors <\/strong>&ndash; an unreachable website might occur when its domain doesn&rsquo;t resolve properly due to DNS issues or incorrect entries. Editing the hosts file ensures the IP address is valid.<\/li>\n<\/ul><p>Remember that changes in the hosts file will only apply to your local computer. For example, you must wait for DNS propagation to finish before your website is accessible on other systems.<\/p><h2 class=\"wp-block-heading\" id=\"h-steps-to-edit-hosts-file\">Steps to edit hosts file<\/h2><p>Before editing your hosts file, make sure you have information about the website you want to add, including its domain name and IP address. Since the steps to obtain them differ depending on the <a href=\"\/web-hosting\">web hosting provider<\/a>, check their documentation or contact support.<\/p><figure class=\"wp-block-image size-full\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-web-hosting\" href=\"\/web-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/public\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-how-to-edit-hosts-file-in-windows\">How to edit hosts file in Windows<\/h2><p>Here are the steps to edit the hosts file in a Windows system. The procedure should work for the newer versions of the operating system, like <strong>Windows 11<\/strong> and <strong>10<\/strong>:<\/p><ol class=\"wp-block-list\">\n<li>Open <strong>File Explorer<\/strong> from your taskbar. Alternatively, open the<strong> start menu <\/strong>and locate <strong>File Explorer<\/strong>.<strong><\/strong><\/li>\n\n\n\n<li>Navigate to <strong>C:\\ <\/strong>&rarr; <strong>Windows<\/strong> &rarr; <strong>System32 <\/strong>&rarr; <strong>Drivers<\/strong> &rarr; <strong>etc<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69dfbaf1c6841\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"418\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-windows-file-explorer.png\/public\" alt=\"The hosts file on Windows' File Explorer\" class=\"wp-image-120130\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-windows-file-explorer.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-windows-file-explorer.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-windows-file-explorer.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-windows-file-explorer.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-windows-file-explorer.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Right-click the <strong>hosts <\/strong>file and click<strong> Open with<\/strong>.<\/li>\n\n\n\n<li>Select your preferred text or code editor. For this tutorial, we will use <strong>Notepad<\/strong>. Click <strong>Just Once<\/strong>.<\/li>\n\n\n\n<li>At the bottom of the document, add a new line specifying the IP address-domain pair. The setting should look like this:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&amp;nbsp;185.185.185.185 domain.com<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Hit <strong>Ctrl + S<\/strong> to save the changes.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69dfbaf1c84d2\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1410\" height=\"808\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/07\/add-ip-address-on-hosts-file.png\/public\" alt=\"A new entry specifying the domain and IP address on the hosts file\" class=\"wp-image-113270\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/07\/add-ip-address-on-hosts-file.png\/w=1410,fit=scale-down 1410w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/07\/add-ip-address-on-hosts-file.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/07\/add-ip-address-on-hosts-file.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/07\/add-ip-address-on-hosts-file.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/07\/add-ip-address-on-hosts-file.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1410px) 100vw, 1410px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro tip<\/h4>\n                    <p>To disable a setting, add a hash sign (<strong>#<\/strong>) at the beginning of the line, like <strong># 185.185.185.185 domain.com<\/strong>. This is safer than deleting the entry since you can easily reactivate it by removing the symbol.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\">How to edit hosts file in macOS<\/h3><p>The easiest way to edit the hosts file in macOS is using commands via Terminal. Here are the steps:<\/p><ol class=\"wp-block-list\">\n<li>Open <strong>Spotlight search<\/strong> by clicking the <strong>magnifying glass <\/strong>icon on the top menu or by pressing <strong>Command<\/strong> + <strong>Space<\/strong>.<\/li>\n\n\n\n<li>Search and enter <strong>Terminal<\/strong>.<\/li>\n\n\n\n<li>Run the following command to open the hosts file. We will use the <a href=\"\/tutorials\/how-to-install-and-use-nano-text-editor\">Nano text editor<\/a> as it is the simplest:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/hosts<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Enter your password to grant administrative privileges if Terminal asks for it.<\/li>\n\n\n\n<li>Scroll down to the bottom of the file and add your domain and its IP address:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">185.185.185.185 domain.com<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Press<strong> Ctrl + X<\/strong>, <strong>Y<\/strong>, and<strong> Enter <\/strong>to save the changes.<\/li>\n<\/ol><p>If you prefer using a graphical user interface, follow these steps instead. Note that the interface might be different depending on your operating system version:<\/p><ol class=\"wp-block-list\">\n<li>Go to your <strong>application dock<\/strong> and click<strong> Finder<\/strong>.<\/li>\n\n\n\n<li>Navigate to the top <strong>menu bar<\/strong> &rarr; <strong>Go<\/strong> &rarr;<strong> Go to Folder<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69dfbaf1ca498\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"430\" height=\"936\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/go-to-folder-on-finder-menu-bar.png\/public\" alt=\"The go to folder button on Finder's menu bar\" class=\"wp-image-120131\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/go-to-folder-on-finder-menu-bar.png\/w=430,fit=scale-down 430w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/go-to-folder-on-finder-menu-bar.png\/w=138,fit=scale-down 138w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/go-to-folder-on-finder-menu-bar.png\/w=69,fit=scale-down 69w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Go to <strong>\/etc<\/strong> and find the hosts file.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69dfbaf1cbc6a\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"752\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-macos-finder.png\/public\" alt=\"The hosts file on macOS' finder\" class=\"wp-image-120132\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-macos-finder.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-macos-finder.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-macos-finder.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-macos-finder.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/06\/the-hosts-file-on-macos-finder.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Right-click the file and select your preferred text editor.<\/li>\n\n\n\n<li>Add your configuration at the bottom of the file.<\/li>\n\n\n\n<li>Save the changes by pressing <strong>Command<\/strong> + <strong>S<\/strong>.<\/li>\n<\/ol><h3 class=\"wp-block-heading\">How to edit hosts file in Linux<\/h3><p>In Linux, you can edit the hosts file using the graphical interface or commands via Terminal. For this tutorial, we will use Terminal since it is more efficient and works the same way regardless of your distribution:<\/p><ol class=\"wp-block-list\">\n<li>Open <strong>Termina<\/strong>l by pressing <strong>Ctrl<\/strong> + <strong>Alt <\/strong>+ <strong>T<\/strong> or accessing it from the application launcher menu.<\/li>\n\n\n\n<li>Then, open the file using your preferred text editor. For this tutorial, we&rsquo;ll use <strong>Nano<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/hosts<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Enter your administrator password. If you log in as<strong> root<\/strong>, you can skip this step.<\/li>\n\n\n\n<li>Add the IP address and domain name at the bottom of the file:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">185.185.185.185 domain.com<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>Hit <strong>Ctrl + X<\/strong>, <strong>Y<\/strong>, and <strong>Enter <\/strong>to save the changes.<\/li>\n<\/ol><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Your operating system&rsquo;s hosts file resolves a domain or hostname to its IP address. Editing this file is helpful if you want to block a specific site or explicitly map a website to its address for accessibility on your local machine<\/p><p>In this article, we have explained how to edit the hosts file in popular operating systems. For Windows users, navigate to<strong> C:\\Windows\\System32\\Drivers\\etc <\/strong>using <strong>File Explorer <\/strong>and edit the file using <strong>Notepad<\/strong>.<\/p><p>Meanwhile, the steps to edit the hosts file in macOS and Linux are similar. Open <strong>Terminal <\/strong>and run <strong>sudo<\/strong> <strong>nano \/etc\/hosts <\/strong>to open the file. After adding the domain and its corresponding IP address, hit<strong> Ctrl <\/strong>+<strong> X<\/strong>, <strong>Y<\/strong>, and<strong> Enter <\/strong>to save the changes.<\/p><h2 class=\"wp-block-heading\" id=\"h-edit-hosts-file-faq\">Edit hosts file FAQ<\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1734336925612\"><h3 class=\"schema-faq-question\">How do I locate the hosts file?<\/h3> <p class=\"schema-faq-answer\">In Windows, you can find the hosts file by navigating to the <strong>C:\\Windows\\System32\\Drivers\\etc  <\/strong>path using Explorer. For macOS and Linux, the file is located in the<strong> \/etc\/hosts <\/strong>directory. You can access it using<strong> Terminal<\/strong> or applications like <strong>Finder <\/strong>in macOS. <\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1734336927646\"><h3 class=\"schema-faq-question\">What operating systems use a hosts file?<\/h3> <p class=\"schema-faq-answer\">The hosts file is an essential networking component of operating systems. Due to its importance, you can find this file in any modern operating system, including Windows, macOS, and Linux. <\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1734336928247\"><h3 class=\"schema-faq-question\">Why modify the hosts file?<\/h3> <p class=\"schema-faq-answer\">Modifying the hosts file ensures your website is accessible since you explicitly add the IP address to its domain name or hostname. Moreover, you can block or redirect malicious websites by assigning other IP addresses to their domain names.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Your computer&rsquo;s hosts file maps a domain name to its IP address. If you experience an unreachable web page or [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/how-to-edit-hosts-file\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to edit hosts file on Windows, macOS and Linux","rank_math_description":"Learn how to edit your system\u2019s hosts file: Navigate to C:WindowsSystem32Driversetchost; 2. Open the hosts file using Notepad + more.","rank_math_focus_keyword":"edit hosts file","footnotes":""},"categories":[22635,22631],"tags":[],"class_list":["post-547","post","type-post","status-publish","format-standard","hentry","category-configuration-and-management","category-domains"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-edit-hosts-file","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/modifier-fichier-hosts","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/editar-archivo-hosts","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-edit-host-file","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-edit-hosts-file","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-edit-hosts-file","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-edit-hosts-file","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/editar-archivo-hosts","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/editar-archivo-hosts","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/editar-archivo-hosts","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-edit-hosts-file","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-edit-hosts-file","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-edit-hosts-file","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-edit-hosts-file","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=547"}],"version-history":[{"count":33,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/547\/revisions"}],"predecessor-version":[{"id":120133,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/547\/revisions\/120133"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}