How to Change Hosts File: Modify System Files and Flush DNS
Changing the hosts file is important for developers and tech enthusiasts who want to modify system files and manage local domain resolution. This guide will show you how to edit your hosts file so you can easily change DNS settings on your machine. Whether you are testing websites or fixing problems, knowing how to flush DNS after making changes will help you see the results immediately.
Hosts File
The host's file will allow you to set IP addresses for domains on your local machine. These files can override the authoritative DNS settings for your domain, so this can be useful for seeing what a domain will display if pointed to a different server. A typical hosts file will have one or more lines referencing your 'localhost'(your computer).
This is very beneficial for development purposes, as it allows you to make changes on a server other than the one loaded by your domain when visitors access your page.
Change Hosts File
To change the host your domain loads from, you will need to know the correct IP for your server. Bluehost servers will require you to use the IP address displayed under Server Information in your cPanel.
Edit System Files
You can change the host your local computer loads your website from by directly editing your system's hosts file. This method will be more straightforward if you are an experienced user of your local PC's operating system.
All operating systems will have a hosts file like our example:
127.0.0.1 localhost
123.45.67.89 www.example.com
#98.76.54.32 www.another-example.com
Add the second line in this example to your host's file with the following edits:
- Replace "123.45.67.89" with the IP address from your cPanel.
- Replace "www.example.com" with your actual domain name.
To undo this change, deactivate the line by prefacing it with a "#" (as shown on the third line in the example above). This will cause the line to be ignored.
Warning: Remember to undo any changes you make after you're done previewing your site. Otherwise, any of these changes could prevent your domain from loading the correct DNS.
Flush DNS
Once you have modified your host's file, we recommend flushing your DNS cache to quickly see the changes. For more information on flushing cache, please see Flush DNS.
Summary
Changing your hosts file is basically important when managing local DNS settings or editing system files. According to the step-by-step guide, your hosts file can be edited to enable you to browse websites to test them. Afterward, flush the DNS cache so the changes can take place.
If you need further assistance, feel free to contact us via Chat or Phone:
- Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
- Phone Support -
- US: 888-401-4678
- International: +1 801-765-9400
You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.