How Do I Change My Hosts File?

The hosts file is a system file that helps map hostnames to their IP addresses. It lets people connect to websites with easy-to-remember domain names instead of their IP addresses. The file resolves domain names locally without querying DNS nameservers

It lets users set IP addresses for domains on their computers for a faster name resolution. You can also block ads, malicious websites, and tracking sites in the hosts files to prevent your computer from connecting to them. The file also lets users preview or test their website before pointing it to a new server.

You can edit entries in your host file in a couple of steps, and here’s how.

Windows 8 and 10

You can find your system’s hosts file on Notepad.

If you use a Windows computer, take these steps to open the file and make your changes:

  • Find Notepad using the search bar, right-click the app, and select Run as administrator.
How Do I Change My Hosts File?, Windows 8 and 10
  • Click File to launch the app, then choose Open.
  • Go to c:\Windows\System32\drivers\etc.
  • Switch the file type from “Text Documents (*.txt) to “All Files” and open the hosts file.
How Do I Change My Hosts File?, Windows 8 and 10 2
  • Make your changes in the host file, click Files > Save to apply the changes.

You can disable a line by prefacing it with the hashtag sign (#), for example: 


The hashtag makes the hosts file to ignore the line during name resolution, resolving the name via the domain name system (DNS). You could also block access to any domain by replacing its IP address with the loopback IP addresses of for IPv4 addressing or ::1 for IPv6 addressing.


For Linux computers, follow these steps to change its hosts file.

  • Use CTRL + ALT + T on your keyboard to open the Terminal
  • Execute this command sudo nano /etc/hosts  at the command prompt to open the host file.
  • Enter your password if the system asks for it.
  • Make your desired changes and save using the Control and X key combination.

Mac OS

Here’s how to edit the hosts file on Mac computers:

  • Log in to Mac with admin access—you need administrator privileges to edit Mac’s hosts file.
  • Open the Terminal by selecting Applications > Utilities > Terminal.
  • Run this command sudo nano /private/etc/hosts to open the hosts file. 
  • Edit your entries and save using the Control and X key combination plus Y and Enter.

Need Help?

If you have questions regarding editing your local hosts file, reach out to our support. We’re always available and ready to help.

Was this helpful?

What’s your goal today?

1. Find the right Managed VPS 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 lighting fast

We guarantee to make your WordPress site 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.

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


Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.