How to Preview Your WPCloud Website Using the Hosts File Method

Using the Hosts File Method

Overview

The hosts file method is the professional standard for previewing websites before DNS changes. This guide explains how to safely view your website on WPCloud servers before updating your DNS records. This is the same method our migration team uses, ensuring 100% accuracy in preview testing.

Why We Use This Method: Unlike temporary domain names, which require URL rewriting and can't perfectly replicate your site's configuration, the hosts file method shows you exactly how your website will appear after the DNS change.

Prerequisites

  • Administrator/root access to your computer
  • Your website's new IP address (provided by WPCloud)
  • Your domain name(s)
  • Text editor (Notepad for Windows, Terminal for macOS)

Important Safety Notes

⚠️ Before You Begin:

  • Back up your existing hosts file
  • Make note of any changes you make
  • Follow instructions exactly as written
  • Keep track of which domains you've added

Detailed Instructions

Windows 10/11 Instructions

  1. Open Notepad as Administrator
      • Press Windows key
      • Type "Notepad"
      • Right-click on Notepad
      • Select "Run as administrator"
      • Click "Yes" if prompted
       
  1. Access the Hosts File
    1. File Location: C:\\Windows\\System32\\drivers\\etc\\hosts
      
      • Click File > Open
      • Navigate to C:\Windows\System32\drivers\etc\
      • Change "File type" dropdown to "All Files (.)"
      • Select "hosts" file
       
  1. Modify the Hosts File
      • Scroll to the bottom of the file
      • Add your new entry in this format:
      [WPCloud_IP] [domain.com] [www.domain.com]
      
      • Example:
      192.168.1.1 example.com www.example.com
      
       
  1. Save Changes
      • Click File > Save
      • If you get a permission error, ensure you opened Notepad as administrator
  1. Flush DNS Cache
      • Press Windows key
      • Type "cmd"
      • Right-click "Command Prompt"
      • Select "Run as administrator"
      • Type the following command:
      ipconfig /flushdns
      
      • You should see: "Successfully flushed the DNS Resolver Cache"
 

macOS Instructions

  1. Open Terminal
      • Press Command + Space
      • Type "Terminal"
      • Press Enter
       
  1. Access the Hosts File
    1. sudo nano /private/etc/hosts
      
      • Enter your administrator password when prompted
      • Note: You won't see the password as you type
       
  1. Modify the Hosts File
      • Use arrow keys to move to the end of the file
      • Add your new entry in this format:
      [WPCloud_IP] [domain.com] [www.domain.com]
      
      • Example:
      192.168.1.1 example.com www.example.com
      
  1. Save Changes
      • Press Control + X
      • Press Y to confirm
      • Press Enter to save
  1. Flush DNS Cache
    1. # For macOS 12 (Monterey) and later:
      sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
      
      # For macOS 10.10.4 through 11:
      sudo killall -HUP mDNSResponder
      

Verifying Your Website

Primary Verification Method

  1. Clear Browser Cache
      • Chrome: Press Ctrl + Shift + Delete (Windows) or Command + Shift + Delete (macOS)
      • Select "Clear data"
       
  1. Access Your Website
      • Open a new browser window
      • Enter your domain name with HTTPS:
      <https://yourdomain.com>
      
  1. WPCloud Verification
      • Add "/wpc.html" to your domain:
      <https://yourdomain.com/wpc.html>
      
      Success: If you see the WPCloud verification page, you're viewing the correct server Failure: If you get a 404 error, you may still be viewing the old server

Troubleshooting

Common Issues and Solutions

  1. Browser Still Shows Old Site
      • Clear browser cache completely
      • Try incognito/private browsing mode
      • Try a different browser
  1. HTTPS Certificate Warnings
      • Expected behavior - proceed to site
      • SSL will work properly after DNS change
  1. Firefox-Specific Issues
      • Open about:config
      • Search for network.dns.offline-localhost
      • Set to false
      • Alternative: Use Chrome or Edge for testing
  1. Permission Errors
      • Ensure you're using administrator privileges
      • Check file permissions
      • Verify no other programs are editing the hosts file

Best Practices

  1. Document Your Changes
    1. # WPCloud Testing - Added [Date]
      192.168.1.1 domain.com www.domain.com
      
  1. Temporary Changes Only
      • Remove entries after testing
      • Keep a backup of original hosts file
  1. Multiple Domains
      • Add each domain on a new line
      • Include both www and non-www versions

Cleanup Process

  1. Remove Test Entries
      • Follow access steps above
      • Delete or comment out (#) added lines
      • Save file
      • Flush DNS again
  1. Verify Removal
      • Clear browser cache
      • Confirm site resolves to original server

Professional Tips

Why Not Use Temporary Domains?
 

Remember: This method is used by WPCloud's professional migration team and is the most reliable way to preview your site before DNS changes.

 
Did this answer your question?
😞
😐
🤩

Last updated on November 15, 2024