Rate Your Experience

How to edit your hosts file

Modified on: Thu, 14 Jan, 2021

Under Ezoic Name Server Integration and CloudFlare Integration, your site is passed through Ezoic servers so that we can add our services in real time such as AI ads, improved site speed, and sophisticated analytics. 


However, on your origin server (i.e. your hosting service) your site remains unchanged, and sometimes you might want to check what things look like there without turning off Ezoic for your site visitors.


In order to do this, you’ll need to edit the hosts file of your computer. This is a quick, simple process, and takes just 2 minutes to do. What it does is tell your computer (and your computer alone) to load a given site from a different IP address than the rest of the internet. So while the rest of the internet continues to see the Ezoic version of your site, you can see exactly what your site looks like on the origin server.


1. Find out the IP address of your origin server


Assuming you’re integrated with Ezoic, this will be in your Ezoic DNS settings - you’ll find these in the Settings section of your publisher dashboard. Typically, this will be the IP address that the @ hostname is pointed to.


image


2. Next, consider what different hostnames or subdomains you might need to access


You’ll need to consider the root domain (‘@’) and the www hostname at a minimum. Some sites might also have others such as the blog hostname. Make sure each hostname that you add is being served by the same IP address.


3. Create a line to add to your hosts file


The line you add to your hosts file should start with the IP address (with no spaces at the beginning of the line), and then specify the various hostnames with only one space inbetween them. So it should look like this:


11.234.56.78 amazingwebsite.com www.amazingwebsite.com blog.amazingwebsite.com


Please note, if you were to leave any of the above hostnames out of the line then they would default to Ezoic. For example, if you edited your hosts file to the following:


11.234.56.78 amazingwebsite.com www.amazingwebsite.com


Then when you navigated to blog.amazingwebsite.com, this would default to the same IP address that the rest of the internet would see.


If your blog subdomain is being drawn from a different IP address you’ll need to use two separate lines as follows (assuming that you want to check them both):


11.234.56.78 amazingwebsite.com www.amazingwebsite.com

78.56.234.11 blog.amazingwebsite.com


4. Add this line to your hosts file


You can find your hosts file in different locations depending on your operating system:


For Windows users: C:\Windows\System32\drivers\etc\hosts

For Linux users: /etc/hosts

For Mac users: /private/etc/hosts


Adding the line to your hosts file is simple, although for Windows users you will need to open the file in Notepad (or other text-editing software) after right-clicking notepad and selecting “Run as Administrator” first. Otherwise, your changes will not be applied to the hosts file.


image


Once you paste the line into your hosts file, just click save.



How to undo your changes


You can undo your changes simply by typing a hash symbol (#) in front of the line. So should you ever need to do this again, you’ll be able to do so by simply removing the hash symbol and saving the file.


image



But what if your changes aren’t going through? A checklist


If you find that it doesn’t seem to be working, run through the following steps to make sure that your hosts file has been correctly edited:


  1. Make sure there are no typos in your hosts file and that you’re using the correct IP address
  2. Make sure there are no extra spaces in the line you’ve added to your hosts file - there shouldn’t be a space at the start of the line and there should only be one space between each element of the line
  3. Make sure there are no contradictory instructions in your hosts file due to duplicate entries (your computer will always default to the first option in the case of duplicate entries)
  4. If your origin server isn’t responding, it could be an issue with their servers. If you’re unable to find out why you can’t access the site from the origin server and you've entered the information in your hosts file correctly, your next port of call will be to your host to make sure everything is ok there.


Loading ...