How to Edit Your Hosts File (And Preview Your Website Before DNS Propagates)
Your computer’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’s IP address, like 192.168.0.1.
The host's file lets you manually map your site’s domain name to the IP address of your site’s new server. That means you’ll be able to fully test out your new site without needing to wait for your DNS changes to propagate.
How To Edit Hosts File On Windows
Step1 : Open Text Editor As Administrator
1. right-click on your text editor’s icon and choose Run as administrator.
Step 2: Open hosts File
1.Go to File → Open in your text editor. Then, browse to the following folder location (you can paste it into the navigation bar to go directly there):
C:\Windows\System32\drivers\etc\
2. You should see a list of files that includes hosts. Click on the hosts file and choose Open:
Step 3: Add New Entries Following Correct Format
3.Now, you can add as many new entries as needed.
Use this format:
1.2.3.4 yoursite.com
Where 1.2.3.4 is your IP address and yoursite.com is your domain name
How To Edit Hosts File On Linux
1.first open Terminal. Then, use this command sudo nano /etc/hosts
2.Add New Entries Following Correct Format
Use this format:
1.2.3.4 yoursite.com
Where 1.2.3.4 is your IP address and yoursite.com is your domain name
3.Make your changes. then,save your changes by typing Control + X.
How To Preview Site Without Editing Hosts File In Linux
if you just want a simple way to preview your site before DNS propagates, you can use the free SkipDNS.link tool.
Here you need to enter your domain name and server IP address. Then, click the button to see how your site looks at that server:
How To Edit Hosts File On Mac
To edit the hosts file on Mac, you’ll need to be logged in as a user with administrator privileges. You’ll also need the password for your administrator account.
Step 1: Open Terminal
1. To get started, open the Terminal application. You can find it by clicking on the Finder icon and then going to Applications → Utilities:
Step 2: Enter Command In Terminal
1.In terminal, enter the following command and then press enter:
sudo nano /private/etc/hosts
Step 3: Add New Entries Following Correct Format
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.
Just as with other operating systems, use the following format:
1.2.3.4 yoursite.com
Where 1.2.3.4 is your IP address and yoursite.com is your domain name
To save your changes, type Control + X.