...
Skip to main content
Print

How Do I Edit the Local Hosts File on My PC or Mac?

With the hosts file you make your own computer send a domain name to a different IP address. This lets you view and test your website on a new server, for example during a migration, before you change the DNS. The change only applies to your own computer. Visitors will not notice anything.

Editing the hosts file on Windows

  1. Open Notepad or Notepad++ as administrator.
  2. Open the file C:\Windows\System32\drivers\etc\hosts.
  3. Add a line at the bottom with the IP address of the new server and your domain name, for example:
111.222.333.444  jedomein.nl  www.jedomein.nl
  1. Save the file and reopen your browser.

Editing the hosts file on a Mac

  1. Press ⌘ + Space, type Terminal and press Enter.
  2. Open the hosts file with this command and enter your Mac password. You will not see any characters while typing: that is normal.
sudo nano /private/etc/hosts
  1. Use the arrow keys to go to a new line and add one line per record:
111.222.333.444  jedomein.nl
111.222.333.444  www.jedomein.nl
  1. Save with Control + O and Enter, and close Nano with Control + X.

Website not visible yet?

Still seeing the old website? Then clear your browser cache and try again. Do not forget to remove the lines again when the migration is complete.

Table of Contents