Setting Up a Hosts File for Your Local Computer

When DNS changes are made to your site, you may not be able to see it via your web browser right away due to a process called "DNS propagation" (What is DNS propagation?)

DNS propagation can take anywhere from 5 minutes to 48 hours. Until it is complete, you may not be able to put your domain name into your browser or FTP client and have it find the new IP address properly. However, we can trick DNS into knowing where the domain now resides. To do this, you can edit the local "hosts" file on your computer. The hosts file contains IP addresses and their domain name mappings, which replaces the function of a DNS server.

Sadly, this is not something we can do for you, as the file exists on your local computer. However, we hope these steps will be helpful!

On Windows computers, the hosts file is usually located here: C:\WINDOWS\system32\drivers\etc\hosts

On Mac and Linux computers, the file is located here: /etc/hosts

This file is a plain text file, so open it using a text editor (NotePad, vim, et cetera) and not a word processor like Microsoft Word; word processors will insert unwanted characters.

When you first open the hosts file, you should see an entry that looks like this:

127.0.0.1 localhost.localdomain localhost

That may be all that's there, and it's completely ok if there is more information present. If there are more lines than localhost, we do need to make sure an existing entry for your domain doesn't exist. Look through the lines in the file to ensure it's not there. If it is present, we will simply change the IP address on that line.

If the domain we're working with does not exist in your hosts file, add a new line in the same format for your domain:

xxx.xxx.xxx.xxx www.example.com example.com

Use your new IP address in place of the "xxx.xxx.xxx.xxx" and your domain for the www.example.com example.com. If you're unsure what your IP address for the domain is, you can see it within cPanel, or you can contact support and ask us anytime.

Here are some operating-system-specific options to help you if you're stuck:

For Windows Vista and Windows 7:

  1. Click Start, search for "Notepad"
  2. Right-click and select "Run as Administrator". This should launch notepad with the elevated privileges that are needed to save changes to system files.
  3. Open the host file from the File menu, edit or add the appropriate line following the instructions above, and save.
  4. It's a good idea to remember to remove this line after a few days, once DNS propagation is complete - but don't delete the whole file; just remove the line we added.

 

For Mac OSX:

  1. Open the Terminal.app either by typing Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.
  2. Open the hosts file by typing in the Terminal that you have just opened: "sudo nano /private/etc/hosts" (without quotes.) If the file does not exist, please try "sudo nano /etc/hosts" (again without quotes.)
  3. Type your user password when prompted.
  4. Edit the hosts file. The hosts file contains some comments (lines starting with the # symbol), as well as some default hostname mappings (e.g. 127.0.0.1 – localhost). Simply append your new mappings underneath the default ones. You can navigate the file using the arrow keys, and when you've added the right information, hit control-x to exit, making sure to say yes to saving the file.
  5. It's a good idea to remember to remove this line after a few days, once DNS propagation is complete - but don't delete the whole file; just remove the line we added.
  6. Flush the DNS cache - On Leopard you can issue a simple Terminal command to flush the DNS cache, and have your host file changes to take immediate effect: "dscacheutil -flushcache" without quotes.

 

Additional Resources:

https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

  • 0 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

Can I Transfer My Current Domain(s) to Online Presence Solutions?

Absolutely! We will be happy to have you transfer your existing domain or domains to our...

Can I Transfer My Current Domain(s) to Online Presence Solutions?

Absolutely! We will be happy to have you transfer your existing domain or domains to our...

How to Create and/or Download a Backup?

Generating and downloading a backup within cPanel is a simple and painless process, and so...

Getting Started with cPanel

cPanel is a very nice way of managing your domain and hosting account with Black Chicken Host....

Migrating from Plesk to cPanel Yourself

A Plesk-to-cPanel migration is perhaps less painful than some. Here are some basic steps to help...

Powered by WHMCompleteSolution