Seamlessly Host, Manage & Grow Your Web hosting Site
  • Free & Effortless Website Migration
  • 24/7 Worry-Free Support
  • Anytime Money-back Guarantee
See Web hosting Plans
Spending over 2 hours weekly on growing your website and still using shared hosting?
You Must Read This!

How to Edit Your Hosts File – Windows, Linux, and macOS Guide

Your system’s Hosts file is an essential part of the OS that maps hostnames to IP addresses. This is done via textual commands, which act as a name resolution alternative. Here’s what that means in plain terms. 

As a hosting user moving to a new provider, you can easily test if your website works properly before pointing the domain to the new server. Knowing that, here is how you can edit your Hosts file on the most popular operating systems:

How to Edit Your Hosts File on Windows 8/10?

Most Windows users follow absolutely the same steps, only your visual environment may differ.

Step 1 – Find Notepad and Run as Administrator

Click the Windows key and type Notepad in the search bar. Before you open it, right-click the mouse over it and choose the Run as Administrator option.

IMPORTANT: Don’t forget to open the notepad as an administrator or you won’t have enough rights to save the changes to the Hosts file.

Step 2 – Locate the Hosts File

Inside the Notepad, open the File menu and click the Open option. This will open your main PC folder. To navigate straight to the Hosts file, you can type the following path in the address bar:


The system may ask you about the desired app to open the file, you can choose Notepad again. Inside, your Hosts file will look a little something like this:

Step 3 – Edit the Hosts File

Here is where you will be doing alterations to point your domain to the new server just for your computer. Start from the bottom line and add your records like this:

{IP Address} {} {}

IMPORTANT: Make sure to add both the www and non-www versions of your domain. Also, you need to add a line for every domain name you wish to test.

Step 4 – Delete Changes after Testing

One important step you should not forget is returning everything as it was before you made the change. Delete the lines you added and return the Hosts file to its default state.

IMPORTANT: The changes you make to the Hosts file point the domains to your new server just for your computer. Visiting the website from another device will load it from the old server until you change the name servers.

How to Edit Your Hosts File on Linux?

Step 1 – Open the Terminal

Linux users easily dig through their system via the Terminal that all distributions come with. Although the steps may vary a little between distributions, they follow the same general logic.

Right-click on your desktop and choose the option Open Terminal. Alternatively, you can do the same via Applications -> Utilities -> Terminal. 

Step 2 – Find and Open the Hosts File

Locating your Hosts file on Linux is as simple as typing a single command in the Terminal. You can do so with:

sudo vim /etc/hosts

IMPORTANT: In the above example, Vim is just one of many text editors you can use in Linux. You can replace this part with any other editor.

Running the command will prompt you to enter your password so it can identify you as an administrator. 

Step 3 – Modify the Hosts File

The method of editing your Hosts file is pretty much the same as for Windows users. You need to type:

{IP Address} {} {}

Naturally, each of your domains goes on a separate new line. When prompted to save the changes in the end – press Y

Remember to revert the changes once you are done with your name resolution tests.

How to Edit Your Hosts File on macOS?

Step 1 – Open the Terminal

Similar to Linux, you can navigate the macOS environment via a terminal. To get there, open the Finder and go to Applications -> Utilities -> Terminal

Make sure to be logged in as an Administrator so you can have superuser rights for the system files.

Step 2 – Find the Hosts File

Inside the command-based screen, type the command to enter your /etc/hosts folder:

sudo nano /etc/hosts

Again, Nano is just one of the many text editors you may choose to use with your Mac. To confirm your rights as an admin, you will have to type your system password

Step 3 – Edit the Hosts File

Once you open the file in your text editor, you can add your commands on the bottom. The logic is that your IP address comes first and the domain – second. 

Here is an example:

To save the newly edited file, hit Ctrl+X and then confirm with Y.

We hope this guide has helped you with editing your Hosts file and testing your hosting network. If you are experiencing any difficulties, you can contact the Scala Team for support.

Was this article helpful?

What’s your goal today?

1. Find the right Web hosting solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lightning-fast

We guarantee to make your website load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Make your website lighting fast—or your money back
Slow websites lose visitors and sales. See how you can surf tsunami sized traffic spikes—or any traffic—with ease with ScalaHosting. Fill out the form, and we’ll be in touch!
Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.


Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2024

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain