{"id":784,"date":"2019-01-12T02:06:00","date_gmt":"2019-01-12T09:06:00","guid":{"rendered":"https:\/\/pagely.com\/kb\/?post_type=ht_kb&#038;p=784"},"modified":"2020-01-31T13:57:39","modified_gmt":"2020-01-31T20:57:39","slug":"edit-hosts-file-wordpress","status":"publish","type":"ht_kb","link":"https:\/\/pagely.com\/kb\/en\/edit-hosts-file-wordpress\/","title":{"rendered":"How to Edit Your Hosts File (And Preview Your Website Before DNS Propagates)"},"content":{"rendered":"<p>Your computer&#8217;s <strong>hosts <\/strong>file is a simple text file that maps hostnames to IP addresses. In practical terms, that means that it maps a domain, like pagely.com, to a server&#8217;s IP address, like 192.168.0.1.<\/p>\n<p>Normally, this process is handled by the <a href=\"https:\/\/pagely.com\/blog\/dns-wordpress\/\">Domain Name System (DNS)<\/a> when you&#8217;re using the Internet. However, the hosts file provides an alternative method to map hostnames to IP addresses without using DNS.<\/p>\n<p>As a WordPress user, the hosts file can be especially helpful when you <a href=\"https:\/\/support.pagely.com\/hc\/en-us\/articles\/200237270-How-do-I-migrate-my-WordPress-Site-to-Pagely-\">migrate a WordPress site<\/a> to a new host or otherwise change your domain&#8217;s nameservers. For example, if you move from Host A to Host B, you&#8217;ll first migrate all of your site&#8217;s files. Then, you&#8217;ll need to <a href=\"https:\/\/support.pagely.com\/hc\/en-us\/articles\/200237390-How-do-I-point-traffic-to-Pagely-DNS-CNAME\">update your domain&#8217;s nameservers<\/a> to point to Host B (<em>instead of Host A<\/em>).<\/p>\n<p>However, DNS takes some time to update, which means that your domain name might still take you to Host A when you really want to end up at Host B to see if your newly migrated site is working properly.<\/p>\n<p>The <strong>hosts<\/strong> file lets you fix that by manually mapping your site&#8217;s domain name to the IP address of your site&#8217;s new server. That means you&#8217;ll be able to fully test out your new site without needing to wait for your DNS changes to propagate.<\/p>\n<p>In this article, you&#8217;ll learn:<\/p>\n<ul>\n<li><a href=\"#hosts\">How the hosts file works<\/a><\/li>\n<li><a href=\"#windows\">How to edit hosts file on Windows<\/a><\/li>\n<li><a href=\"#mac\">How to edit hosts file on Mac<\/a><\/li>\n<li><a href=\"#linux\">How to edit hosts file on Linux<\/a><\/li>\n<\/ul>\n<p>Then, we&#8217;ll also share a beginner-friendly tool that lets you preview your website on a new server before DNS propagates <em>without<\/em> the need to edit your hosts file, though it&#8217;s not quite as flexible as editing your hosts file.<\/p>\n<h2><a id=\"hosts\"><\/a>How The hosts File Works At A Basic Level<\/h2>\n<p>The default hosts file is quite simple. It&#8217;s comprised of two things:<\/p>\n<ol>\n<li><strong>IP Address<\/strong> &#8211; this is the IP address of the server that you want to map a domain to.<\/li>\n<li><strong>Hostname<\/strong> &#8211; usually, this is the domain name that you want to map to the associated IP address.<\/li>\n<\/ol>\n<p>You can also <em>optionally<\/em> add comments by using the # sign, which is helpful if you want to remind yourself about the purpose of each entry.<\/p>\n<p>Here&#8217;s what the default hosts file looks like:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-785\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Example of hosts file\" width=\"863\" height=\"460\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0.png 863w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-300x160.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-768x409.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-50x27.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-60x32.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-35x19.png 35w\" data-sizes=\"(max-width: 863px) 100vw, 863px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-785\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0.png\" alt=\"Example of hosts file\" width=\"863\" height=\"460\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0.png 863w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-300x160.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-768x409.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-50x27.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-60x32.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-35x19.png 35w\" sizes=\"(max-width: 863px) 100vw, 863px\" \/><\/noscript><\/p>\n<p>You can also add multiple hostnames to an <a href=\"https:\/\/pagely.com\/blog\/ipv4-vs-ipv6\/\">IP address<\/a> if needed. If you want to add multiple hostnames, you just add them both to the same line. For example, this lets you include both <strong>yoursite.com<\/strong> and <strong>www.yoursite.com<\/strong>.<\/p>\n<p>Here&#8217;s an example of what the hosts file looks like with three entries:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-786\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"entries in hosts file\" width=\"906\" height=\"447\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png 906w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-300x148.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-768x379.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-50x25.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-60x30.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-35x17.png 35w\" data-sizes=\"(max-width: 906px) 100vw, 906px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-786\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png\" alt=\"entries in hosts file\" width=\"906\" height=\"447\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png 906w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-300x148.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-768x379.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-50x25.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-60x30.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-35x17.png 35w\" sizes=\"(max-width: 906px) 100vw, 906px\" \/><\/noscript><\/p>\n<p>If you want to add new entries to the hosts file, you&#8217;ll need the IP address of the server that you want to map a hostname to. If you&#8217;re hosting at Pagely, you can find your server&#8217;s IP address in the <strong>Advanced Options <\/strong>area of your app:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-787\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Pagely server IP\" width=\"643\" height=\"369\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-1024x587.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-1024x587.png 1024w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-300x172.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-768x440.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-50x29.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-60x34.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-35x20.png 35w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2.png 1179w\" data-sizes=\"(max-width: 643px) 100vw, 643px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-787\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-1024x587.png\" alt=\"Pagely server IP\" width=\"643\" height=\"369\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-1024x587.png 1024w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-300x172.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-768x440.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-50x29.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-60x34.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2-35x20.png 35w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-2.png 1179w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><\/noscript><\/p>\n<h2><a id=\"windows\"><\/a>How To Edit Hosts File On Windows<\/h2>\n<p>To edit the hosts file on Windows, you will need Administrator access. If you&#8217;re working on your own computer, that shouldn&#8217;t be an issue. But if you&#8217;re on a company-provided computer, you might not have that access.<\/p>\n<p>This same general approach should work no matter if you&#8217;re using Windows 10, Windows 8, Windows Vista, or even older versions. For reference, though, the screenshots in our tutorial are from Windows 10.<\/p>\n<h3>Step 1: Open Text Editor As Administrator<\/h3>\n<p>To get started, you&#8217;ll need to open your preferred text editor <strong><em>with administrator privileges<\/em><\/strong>.<\/p>\n<p>To do that, right-click on your text editor&#8217;s icon and choose <strong>Run as administrator<\/strong>.<\/p>\n<p>We&#8217;ll use Notepad++ for this example, but you can use any text editor:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-788\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Run as admin\" width=\"764\" height=\"303\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1.png 764w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-300x119.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-50x20.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-60x24.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-35x14.png 35w\" data-sizes=\"(max-width: 764px) 100vw, 764px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-788\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1.png\" alt=\"Run as admin\" width=\"764\" height=\"303\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1.png 764w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-300x119.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-50x20.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-60x24.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-1-35x14.png 35w\" sizes=\"(max-width: 764px) 100vw, 764px\" \/><\/noscript><\/p>\n<p>Once you open the program, you should see <strong>[Administrator]<\/strong> at the top, which confirms that the program does have administrator privileges:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-789\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Administrator access\" width=\"765\" height=\"217\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2.png 765w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-300x85.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-50x14.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-60x17.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-35x10.png 35w\" data-sizes=\"(max-width: 765px) 100vw, 765px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-789\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2.png\" alt=\"Administrator access\" width=\"765\" height=\"217\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2.png 765w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-300x85.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-50x14.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-60x17.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-2-35x10.png 35w\" sizes=\"(max-width: 765px) 100vw, 765px\" \/><\/noscript><\/p>\n<h3>Step 2: Open hosts File<\/h3>\n<p>Go to <strong>File \u2192 Open<\/strong> in your text editor. Then, browse to the following folder location (<em>you can paste it into the navigation bar to go directly there<\/em>):<\/p>\n<p><code>C:\\Windows\\System32\\drivers\\etc\\<\/code><\/p>\n<p>You should see a list of files that includes <strong>hosts<\/strong>. Click on the <strong>hosts<\/strong> file and choose <strong>Open<\/strong>:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-790\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Open Hosts Fine\" width=\"781\" height=\"471\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3.png 781w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-300x181.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-768x463.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-50x30.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-60x36.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-35x21.png 35w\" data-sizes=\"(max-width: 781px) 100vw, 781px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-790\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3.png\" alt=\"Open Hosts Fine\" width=\"781\" height=\"471\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3.png 781w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-300x181.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-768x463.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-50x30.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-60x36.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-3-35x21.png 35w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><\/noscript><\/p>\n<h3>Step 3: Add New Entries Following Correct Format<\/h3>\n<p>Now, you can add as many new entries as needed.<\/p>\n<p>Use this format:<\/p>\n<p><code>1.2.3.4 yoursite.com<\/code><\/p>\n<p>Enter each IP address on its own line. For each IP address, you can add multiple hostnames on the same line.<\/p>\n<p>Here&#8217;s an example of what it might look like:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-786\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"entries in hosts file\" width=\"906\" height=\"447\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png 906w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-300x148.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-768x379.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-50x25.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-60x30.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-35x17.png 35w\" data-sizes=\"(max-width: 906px) 100vw, 906px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-786\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png\" alt=\"entries in hosts file\" width=\"906\" height=\"447\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1.png 906w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-300x148.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-768x379.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-50x25.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-60x30.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-0-1-35x17.png 35w\" sizes=\"(max-width: 906px) 100vw, 906px\" \/><\/noscript><\/p>\n<h2><a id=\"mac\"><\/a>How To Edit Hosts File On Mac<\/h2>\n<p>To edit the hosts file on Mac, you&#8217;ll need to be logged in as a user with administrator privileges. You&#8217;ll also need the password for your administrator account.<\/p>\n<h3>Step 1: Open Terminal<\/h3>\n<p>To get started, open the <strong>Terminal<\/strong> application. You can find it by clicking on the <strong>Finder<\/strong> icon and then going to <strong>Applications \u2192 Utilities<\/strong>:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-794\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Open Terminal application\" width=\"907\" height=\"524\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1.png 907w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-300x173.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-768x444.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-50x29.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-60x35.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-35x20.png 35w\" data-sizes=\"(max-width: 907px) 100vw, 907px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-794\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1.png\" alt=\"Open Terminal application\" width=\"907\" height=\"524\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1.png 907w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-300x173.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-768x444.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-50x29.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-60x35.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-1-35x20.png 35w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/noscript><\/p>\n<h3>Step 2: Enter Command In Terminal<\/h3>\n<p>In terminal, enter the following command and then press enter:<\/p>\n<p><code>sudo nano \/private\/etc\/hosts<\/code><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-792\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Terminal interface\" width=\"728\" height=\"265\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2.png 728w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-300x109.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-50x18.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-60x22.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-35x13.png 35w\" data-sizes=\"(max-width: 728px) 100vw, 728px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-792\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2.png\" alt=\"Terminal interface\" width=\"728\" height=\"265\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2.png 728w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-300x109.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-50x18.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-60x22.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-2-35x13.png 35w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/noscript><\/p>\n<p>If prompted, you might also need to enter your administrator password after running the command.<\/p>\n<h3>Step 3: Add New Entries Following Correct Format<\/h3>\n<p>Now, you can add as many entries as needed using the text editor. To navigate the text editor, use the arrow keys to move between lines and hit enter to create a new line.<\/p>\n<p>Just as with other operating systems, use the following format:<\/p>\n<p><code>1.2.3.4 yoursite.com<\/code><\/p>\n<p>Enter each IP address on its own line. For each IP address, you can add multiple hostnames on the same line.<\/p>\n<p>Here&#8217;s an example of what it might look like:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-793\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"Edit hosts file in Terminal\" width=\"781\" height=\"441\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3.png 781w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-300x169.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-768x434.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-50x28.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-60x34.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-35x20.png 35w\" data-sizes=\"(max-width: 781px) 100vw, 781px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-793\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3.png\" alt=\"Edit hosts file in Terminal\" width=\"781\" height=\"441\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3.png 781w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-300x169.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-768x434.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-50x28.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-60x34.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-mac-3-35x20.png 35w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><\/noscript><\/p>\n<p>To save your changes, type <strong>Control + X<\/strong>.<\/p>\n<h2><a id=\"linux\"><\/a>How To Edit Hosts File On Linux<\/h2>\n<p>To edit the hosts file on Linux, you can generally follow the same steps as for MacOS.<\/p>\n<p>That is, you first open Terminal. Then, use this command <code>sudo nano \/etc\/hosts<\/code>.<\/p>\n<p>Make your changes. Then, save your changes by typing <strong>Control + X<\/strong>.<\/p>\n<h2>How To Preview Site Without Editing Hosts File<\/h2>\n<p>Finally, if you just want a simple way to preview your site before DNS propagates, you can use the <a href=\"https:\/\/skipdns.link\/\" target=\"_blank\" rel=\"noopener noreferrer\">free SkipDNS.link tool<\/a>.<\/p>\n<p>The only downside with this approach is that it might not work properly if you use a CDN. If that&#8217;s the case, you can try disabling your CDN or just edit your hosts file directly via the methods above.<\/p>\n<p>The tool itself works a lot like the hosts file. That is, you enter your domain name and server IP address. Then, click the button to see how your site looks at that server:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-791\" src=\"https:\/\/pagely.com\/kb\/wp-content\/themes\/sales-kb-childtheme\/src\/assets\/images\/svg\/blank-thumb.svg\" alt=\"SkipDNS\" width=\"788\" height=\"439\" data-src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4.png\" data-srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4.png 788w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-300x167.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-768x428.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-50x28.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-60x33.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-35x19.png 35w\" data-sizes=\"(max-width: 788px) 100vw, 788px\"><noscript><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-791\" src=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4.png\" alt=\"SkipDNS\" width=\"788\" height=\"439\" srcset=\"https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4.png 788w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-300x167.png 300w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-768x428.png 768w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-50x28.png 50w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-60x33.png 60w, https:\/\/pagely.com\/kb\/wp-content\/uploads\/2018\/12\/edit-hosts-file-4-35x19.png 35w\" sizes=\"(max-width: 788px) 100vw, 788px\" \/><\/noscript><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your computer&#8217;s hosts file is a simple text file that maps hostnames to IP addresses. In practical terms, that means that it maps a domain, like pagely.com, to a server&#8217;s [&hellip;]<\/p>\n","protected":false},"author":24,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":""},"ht-kb-category":[155],"ht-kb-tag":[156,10],"acf":[],"_links":{"self":[{"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/ht-kb\/784"}],"collection":[{"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/comments?post=784"}],"version-history":[{"count":0,"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/ht-kb\/784\/revisions"}],"wp:attachment":[{"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/media?parent=784"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=784"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/pagely.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}