chevron_right
chevron_right
How to edit your hosts file
How-To/Instructional

How to edit your hosts file

Last Updated a few days ago

Introduction

Editing your hosts file can be a crucial step when you need to view your website as it appears on your origin server, particularly when using Ezoic's Name Server Integration or CloudFlare Integration. This guide will walk you through the quick and simple process of editing your hosts file, enabling you to bypass the Ezoic servers and see your site directly from your hosting service. In this article, you'll learn how to find your origin server's IP address, determine which hostnames or subdomains to access, create the appropriate lines to add to your hosts file, and troubleshoot any issues that may arise. By following these step-by-step instructions, you can ensure that you accurately view and manage your site without affecting what your visitors see.

Steps

  1. Find out the IP address of your origin server:

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

  2. 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 in between them. For example:

    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. Once you paste the line into your hosts file, just click save.

  5. 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.

Troubleshooting

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. Check for typos: Ensure there are no typographical errors in your hosts file and that you’re using the correct IP address.
  2. Verify spacing: Confirm that there are no extra spaces in the line you’ve added to your hosts file. There shouldn’t be a space at the beginning of the line, and there should only be one space between each element of the line.
  3. Check for duplicate entries: Make sure there are no contradictory instructions in your hosts file due to duplicate entries. Note that your computer will always default to the first option in the case of duplicate entries.
  4. Server response issues: 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 okay there.

Need Further Assistance?

For further assistance, please get in touch with our support team. You can reach us via the following methods:

  • Email: support@ezoic.com

If you are experiencing issues with your origin server, you may also consider contacting your hosting provider directly for more specific support regarding server-related problems.

Loading ...