There was a problem loading the comments.

Edit my hosts file to preview a domain name

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

๐ŸชŸ Windows Instructions

ย 

๐Ÿ“ Hosts File Location:

C:\Windows\System32\drivers\etc\hosts

Steps:

  1. Open Notepad as Administrator:

    • Start โ†’ All Programs โ†’ Accessories

    • Right-click Notepad โ†’ Run as Administrator

  2. In Notepad:

    • Go to File โ†’ Open...

    • Paste this into the "File name" field:

      C:\Windows\System32\drivers\etc\hosts
      
    • Choose "All Files" in the file type dropdown (not ".txt")

  3. Scroll to the bottom of the file and start a new line

  4. Enter the IP address and domain(s):
    (Use at least one space or TAB between entries)

    Example:

    192.168.0.10 example.com test.example.com www.example.com
    
  5. Save the file and close Notepad

  6. Restart all browsers and try loading the domain


๐ŸŽ macOS Instructions

๐Ÿ“ Hosts File Location:

/etc/hosts

Steps:

  1. Open the Terminal (Applications โ†’ Utilities โ†’ Terminal)

  2. Run the following command to open the file in nano editor:

    sudo nano /etc/hosts
    
  3. Enter your admin password if prompted

  4. Scroll to the bottom and add a new line like this:

    192.168.0.10 example.com test.example.com www.example.com
    
  5. Save and exit:

    • Press Control + O to save

    • Press Enter to confirm

    • Press Control + X to exit

  6. Flush your DNS cache:

    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    
  7. Close and reopen your browser


๐Ÿง Linux Instructions

๐Ÿ“ Hosts File Location:

/etc/hosts

Steps:

  1. Open a terminal

  2. Edit the hosts file using your preferred text editor (example using nano):

    sudo nano /etc/hosts
    
  3. Add the entry at the bottom:

    192.168.0.10 example.com test.example.com www.example.com
    
  4. Save and exit:

    • Press Control + O, then Enter to save

    • Press Control + X to exit

  5. Flush the DNS cache (varies by distro):

    • Ubuntu (systemd):

      sudo systemd-resolve --flush-caches
      
    • Or restart your network manager:

      sudo systemctl restart NetworkManager
      
  6. Close and reopen your browser


๐Ÿงผ Cleanup Reminder

This is a temporary fix. Once your DNS changes have propagated:

  • Edit the hosts file again

  • Remove the lines you added

  • Save the file and flush DNS again (for macOS/Linux)


Share via
Did you find this article useful?  

Related Articles

Tags

© Softsys Hosting