What is the hosts file and why do I need to edit it?
When you register a new domain or change hosting providers, it can take up to 48 hours for your domain to "point" to your new hosting account (this is called DNS propagation). During this waiting period, you can't access your website using your domain name.
The hosts file is a simple text file on your computer that acts like a personal phone book for websites. By editing it, you can tell your computer exactly where to find your website, bypassing the need to wait for DNS propagation.
Think of it like this: Instead of waiting for the phone copany to update everyone's phone book, you're writing the new number directly in your personal address book.
Before You Start
You'll need two pieces of information from your hosting welcome email:
- Your domain name (e.g.,
yoursite.co.nz
) - Your server's IP address (this will be provided by your hosting provider)
Step-by-Step Instructions
Windows Users
1. Open Notepad as Administrator
- Press the Windows key and type "notepad"
- Right-click on "Notepad" and select "Run as administrator"
- Click "Yes" when prompted
2. Open the hosts file
- In Notepad, click File → Open
- Navigate to:
C:\Windows\System32\drivers\etc\
- Change the file type dropdown from "Text Documents" to "All Files"
- Select the file named "hosts" (no extension) and click Open
3. Add your website
- Scroll to the bottom of the file
- Add a new line with this format:
YOUR_SERVER_IP yoursite.co.nz YOUR_SERVER_IP www.yoursite.co.nz
- Replace
YOUR_SERVER_IP
with the IP address from your hosting email - Replace
yoursite.co.nz
with your actual domain name
4. Save and test
- Save the file (Ctrl+S)
- Close Notepad
- Open your web browser and visit your domain - you should now see your hosting account!
Mac Users
1. Open Terminal
- Press Cmd+Space and type "terminal"
- Press Enter to open Terminal
2. Edit the hosts file
- Type this command and press Enter:
sudo nano /etc/hosts
- Enter your Mac password when prompted
3. Add your website
- Use the arrow keys to move to the bottom of the file
- Add these lines:
YOUR_SERVER_IP yoursite.co.nz YOUR_SERVER_IP www.yoursite.co.nz
- Replace
YOUR_SERVER_IP
with the IP address from your hosting email - Replace
yoursite.co.nz
with your actual domain name
4. Save and exit
- Press Ctrl+X to exit
- Press Y to save changes
- Press Enter to confirm
- Open your web browser and visit your domain
Linux Users
1. Open Terminal
2. Edit the hosts file
sudo nano /etc/hosts
3. Add your entries (same format as Mac)
4. Save and exit (Ctrl+X, then Y, then Enter)
Important Notes
⚠️ Remember to remove these entries later!
Once your domain is fully propagated (usually within 24-48 hours), you should remove the lines you added to your hosts file. If you don't, your computer will always try to access the old server instead of following normal DNS.
Example
If your server IP is 198.51.100.50
and your domain is myawesomesite.com
, you would add:
198.51.100.50 myawesomesite.com 198.51.100.50 www.myawesomesite.com
Troubleshooting
Not working?
- Make sure you saved the file correctly
- Try clearing your browser cache (Ctrl+F5 on Windows, Cmd+Shift+R on Mac)
- Restart your browser
- Some browsers cache DNS longer - try a different browser
Still having issues?
Contact our support team - we're happy to help walk you through this process!
This method only works on the computer where you edited the hosts file. Other devices will still need to wait for DNS propagation.