{"id":13797,"date":"2025-01-29T09:52:53","date_gmt":"2025-01-29T09:52:53","guid":{"rendered":"https:\/\/www.bodhost.com\/kb\/?p=13797"},"modified":"2026-02-26T14:02:09","modified_gmt":"2026-02-26T14:02:09","slug":"how-to-edit-the-hosts-file-in-windows-macos-and-linux","status":"publish","type":"post","link":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/","title":{"rendered":"How to Edit the Hosts File in Windows, macOS, and Linux"},"content":{"rendered":"<p>In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux, unlocking the power to manage your system\u2019s domain and IP address mappings!<\/p>\n<p>Your computer\u2019s host file is a system configuration file that maps domain names to IP addresses. If you encounter issues accessing certain websites or want to block a site, editing the host file can be a helpful solution. Beforehand we dive into the steps, let\u2019s first understand what a host file is and why you may need to edit it.<\/p>\n<h5><strong>What is a Hosts File?<\/strong><\/h5>\n<p>A hosts file is a local file on your computer that links domain names (like sample.com) with their respective IP addresses. It works like a DNS (Domain Name System) server but is prioritized by your operating system.<br \/>\nWhen your computer wants to access a website, it checks the hosts file first. If the IP address is not found there, it inquiries the DNS server to resolve the address. By modifying this file, you can:<\/p>\n<ul>\n<li>Block websites: Redirect certain domains to local addresses to block access.<\/li>\n<li>Resolve domains: Swiftly make a site available without waiting for DNS propagation.<\/li>\n<li>Fix website access issues: If DNS is down, manually setting the correct IP can restore access.<\/li>\n<\/ul>\n<h5><strong>How to Edit the Hosts File in Windows <\/strong><\/h5>\n<p>Follow these steps to edit the hosts file in Windows 10\/11:<\/p>\n<ol>\n<li>Open File Explorer: You can do this by clicking the File Explorer icon on the taskbar or pressing Windows + E.<\/li>\n<li>Navigate to the Hosts File: Go to C:\\Windows\\System32\\Drivers\\etc\\.<\/li>\n<li>Open the File: Right-click the hosts file and select Open with. Select Notepad (or any text editor).<\/li>\n<li>Edit the Hosts File: At the bottom of the file, add a new line with the IP address and domain. For example:<br \/>\n185.185.185.185 domain.com<\/li>\n<li>Save Your Changes: Press Ctrl + S to save the file.<br \/>\nTip: To disable an entry, add a # before the line (e.g., # 185.185.185.185 domain.com). This lets you quickly reactivate it later.<\/li>\n<\/ol>\n<h5><strong>How to Edit the Hosts File in macOS<\/strong><\/h5>\n<ol>\n<li>Method 1: Using Terminal (Command Line):\n<ol>\n<li>Open Terminal: Press Command + Space, type Terminal, and press Enter.<\/li>\n<li>Edit the Hosts File: Type the following command:<br \/>\nsudo nano \/etc\/hosts<\/li>\n<li>Enter Password: You will be prompted for your password to grant administrative privileges.<\/li>\n<li>Add Your Domain and IP: Scroll down to the bottom of the file and add the following line:<br \/>\n185.185.185.185 domain.com<\/li>\n<li>Save the File: Press Ctrl + X, then press Y to confirm and enter to save.<\/li>\n<\/ol>\n<\/li>\n<li>\u00a0Method 2: Using Finder (Graphical Interface):\n<ol>\n<li>Open Finder: Click the Finder icon in your dock.<\/li>\n<li>Go to Folder: In the top menu, click Go &gt; Go to Folder, and type \/etc.<\/li>\n<li>Open the Hosts File: Find and right-click hosts, then select a text editor to open it.<\/li>\n<li>Edit and Save: Add the domain and IP at the bottom, then save the file by pressing Command + S.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h5><strong>How to Edit the Hosts File in Linux<\/strong><\/h5>\n<ol>\n<li>Open Terminal: Press Ctrl + Alt + T or find Terminal in your application launcher.<\/li>\n<li>Edit the Hosts File: Run the command:<br \/>\nsudo nano \/etc\/hosts<\/li>\n<li>Enter Your Password: If prompted, enter your administrator password.<\/li>\n<li>Add Domain and IP: Add the following at the end of the file:<br \/>\n185.185.185.185 domain.com<\/li>\n<li>Save and Exit: Press Ctrl + X, then Y to confirm, and Enter to save.<\/li>\n<\/ol>\n<p><strong>Conclusion:<\/strong><\/p>\n<p>Editing the hosts file on your system can be useful for various tasks like blocking websites, resolving domains, or troubleshooting network issues. The process is fairly simple in Windows, macOS, and Linux.<\/p>\n<p>\u2022 In Windows, navigate to C:\\Windows\\System32\\Drivers\\etc and edit the hosts file using Notepad.<br \/>\n\u2022 In macOS, use Terminal and the sudo nano \/etc\/hosts command to modify the file.<br \/>\n\u2022 In Linux, edit the file using the same method as macOS through the Terminal.<\/p>\n<p>You can edit the hosts file and make changes to your system\u2019s network configuration when needed.<\/p>\n<p>Wasn\u2019t that easy? Explore our latest web hosting plans today and start enjoying the benefits!<\/p>\n<p>Learn <a href=\"https:\/\/www.bodhost.com\/kb\/how-to-remove-multiple-files-using-command-line\/\" target=\"_blank\" rel=\"noopener\">How to Remove Multiple Files Using the Command Line<\/a>, streamlining file deletion tasks with speed and accuracy for better file management.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux, unlocking the power to manage your system\u2019s domain and IP address mappings!&hellip;<\/p>\n<p><a href=\"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/\" class=\"more-link\">Read More<\/a><\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[837],"tags":[1597,1598],"class_list":["post-13797","post","type-post","status-publish","format-standard","hentry","category-tutorial","tag-edit-the-hosts-file-in-windows","tag-macos"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Edit Hosts File on Windows, macOS &amp; Linux | bodHOST<\/title>\n<meta name=\"description\" content=\"In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux. Follow the simple steps.\" \/>\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.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Edit Hosts File on Windows, macOS &amp; Linux | bodHOST\" \/>\n<meta property=\"og:description\" content=\"In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux. Follow the simple steps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowledge Base - bodHOST\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-29T09:52:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-26T14:02:09+00:00\" \/>\n<meta name=\"author\" content=\"Serena\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Serena\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. 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\":\"Article\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/\"},\"author\":{\"name\":\"Serena\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/ffd3f118493c99471ae5bd4790a55830\"},\"headline\":\"How to Edit the Hosts File in Windows, macOS, and Linux\",\"datePublished\":\"2025-01-29T09:52:53+00:00\",\"dateModified\":\"2026-02-26T14:02:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/\"},\"wordCount\":696,\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"keywords\":[\"Edit the Hosts File in Windows\",\"macOS\"],\"articleSection\":[\"Tutorial\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/\",\"name\":\"How to Edit Hosts File on Windows, macOS & Linux | bodHOST\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\"},\"datePublished\":\"2025-01-29T09:52:53+00:00\",\"dateModified\":\"2026-02-26T14:02:09+00:00\",\"description\":\"In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux. Follow the simple steps.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Tutorial\",\"item\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/category\\\/tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Edit the Hosts File in Windows, macOS, and Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"alternateName\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"contentUrl\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"width\":240,\"height\":240,\"caption\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\"},\"image\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/ffd3f118493c99471ae5bd4790a55830\",\"name\":\"Serena\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g\",\"caption\":\"Serena\"},\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/author\\\/seema\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Edit Hosts File on Windows, macOS & Linux | bodHOST","description":"In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux. Follow the simple steps.","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.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Edit Hosts File on Windows, macOS & Linux | bodHOST","og_description":"In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux. Follow the simple steps.","og_url":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/","og_site_name":"Knowledge Base - bodHOST","article_published_time":"2025-01-29T09:52:53+00:00","article_modified_time":"2026-02-26T14:02:09+00:00","author":"Serena","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Serena","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/#article","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/"},"author":{"name":"Serena","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/ffd3f118493c99471ae5bd4790a55830"},"headline":"How to Edit the Hosts File in Windows, macOS, and Linux","datePublished":"2025-01-29T09:52:53+00:00","dateModified":"2026-02-26T14:02:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/"},"wordCount":696,"publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"keywords":["Edit the Hosts File in Windows","macOS"],"articleSection":["Tutorial"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/","url":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/","name":"How to Edit Hosts File on Windows, macOS & Linux | bodHOST","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/#website"},"datePublished":"2025-01-29T09:52:53+00:00","dateModified":"2026-02-26T14:02:09+00:00","description":"In this guide, you will discover how to easily edit the host file across Windows, macOS, and Linux. Follow the simple steps.","breadcrumb":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.bodhost.com\/kb\/how-to-edit-the-hosts-file-in-windows-macos-and-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Tutorial","item":"https:\/\/www.bodhost.com\/kb\/category\/tutorial\/"},{"@type":"ListItem","position":2,"name":"How to Edit the Hosts File in Windows, macOS, and Linux"}]},{"@type":"WebSite","@id":"https:\/\/www.bodhost.com\/kb\/#website","url":"https:\/\/www.bodhost.com\/kb\/","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","description":"","publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"alternateName":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bodhost.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.bodhost.com\/kb\/#organization","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","url":"https:\/\/www.bodhost.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","contentUrl":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","width":240,"height":240,"caption":"Web Hosting Knowledge Base | bodHOST Hosting FAQ"},"image":{"@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/ffd3f118493c99471ae5bd4790a55830","name":"Serena","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8bf3c9f6220a13a4d46295ad7c38a0c9e351ca3a57d0e417580c8e8b83a12a50?s=96&d=mm&r=g","caption":"Serena"},"url":"https:\/\/www.bodhost.com\/kb\/author\/seema\/"}]}},"_links":{"self":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/13797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/comments?post=13797"}],"version-history":[{"count":4,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/13797\/revisions"}],"predecessor-version":[{"id":13846,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/13797\/revisions\/13846"}],"wp:attachment":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/media?parent=13797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/categories?post=13797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/tags?post=13797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}