How to Test Your Website Before Changing DNS Settings Print

  • dns, website testing, hosts file, temporary url, site preview, dns propagation, website migration, domain testing
  • 12

You can preview your website before updating DNS by using either a temporary URL or by modifying your local hosts file. The temporary URL method works for simple HTML sites, while the hosts file approach is necessary for content management systems like WordPress that require the actual domain name to function properly.

Testing your site before DNS propagation ensures everything works correctly and prevents downtime when you switch hosting providers.

Method 1: Using a Temporary URL for Basic Websites

If you have a basic HTML or simple PHP website that doesn't rely on the domain name to function, you can access it using a temporary URL:

http://X.X.X.X/~username

Replace username with your actual account username and X.X.X.X with your server's IP address. You'll find both pieces of information in your OBHost welcome email.

This method provides immediate access to your files without waiting for DNS changes, making it ideal for quick previews of static websites.

Method 2: Editing Your Hosts File for Complex Sites

For websites running WordPress, Joomla, Magento, or other content management systems that need the actual domain name to operate, you'll need to modify your computer's hosts file. This tells your computer to load your site from the new server instead of following normal DNS routing.

Editing the Hosts File on Windows

Step 1: Locate the Hosts File

The hosts file location depends on your Windows version:

  • Windows NT/2000/XP/2003/Vista/7/8/10/11: C:\windows\system32\drivers\etc\hosts
  • Windows 95/98/Me: C:\windows\hosts

Step 2: Open the File

Right-click on Notepad and select "Run as administrator," then open the hosts file. Running as administrator is required on newer Windows versions to save changes.

Step 3: Backup the Original

Before making changes, use "Save As" to create a backup copy. This lets you restore the original file later.

Step 4: Add Your Domain Entries

The default hosts file looks like this:

127.0.0.1 localhost

Add new lines below with your server IP (found in your welcome email) and domain name. Replace X.X.X.X with your actual server IP and example.com with your domain:

127.0.0.1 localhost
X.X.X.X example.com
X.X.X.X www.example.com

Step 5: Save and Test

Save the file, close all browsers completely, then reopen them. Navigate to your domain, and it will now load from your new hosting account instead of the old one.

Editing the Hosts File on Mac

Step 1: Open Terminal

Open Terminal either through Spotlight search or by navigating to Applications > Utilities > Terminal.

Step 2: Open the Hosts File

Type the following command in Terminal:

$ sudo nano /private/etc/hosts

Enter your Mac user password when prompted.

Step 3: Add Your Domain Mappings

You'll see existing entries starting with # (comments) and default mappings like 127.0.0.1 for localhost. Use the arrow keys to navigate to the bottom of the file and add your new entries:

X.X.X.X example.com
X.X.X.X www.example.com

Replace X.X.X.X with your server IP address and example.com with your actual domain.

Step 4: Save Your Changes

Press Control-O to save the file, press Enter to confirm the filename, then press Control-X to exit the editor.

Step 5: Flush DNS Cache

To make the changes take effect immediately, run this command:

$ dscacheutil -flushcache

After flushing the cache, your browser will load your website from the new server when you visit your domain.

What Happens After Testing?

Once you've confirmed your website works correctly on the new server, you can update your domain's DNS settings with confidence. Remember to remove the hosts file entries after DNS propagation completes (typically 24-48 hours), or your computer will continue bypassing normal DNS lookups.

To restore normal DNS behavior, simply delete the lines you added to the hosts file and save it again. On Mac, remember to flush the DNS cache one more time after removing the entries.

Frequently Asked Questions

How long does it take for the temporary URL to work?

The temporary URL works immediately after your hosting account is created. There's no waiting period because it bypasses DNS entirely and connects directly to your server's IP address.

Will the hosts file method affect other users?

No, modifying your hosts file only affects the computer where you make the change. Other users will continue seeing the website at its current location until you update the actual DNS records for your domain.

Can I test email services before changing DNS?

The hosts file method only affects web traffic, not email. To test email services, you'll need to configure your email client with the server's direct hostname or IP address, which you can find in your welcome email.

What if my website still shows the old content after editing the hosts file?

Make sure you completely closed and reopened your browser after saving the hosts file. Also verify you used the correct IP address and domain name, and on Mac, confirm you ran the DNS flush command. Clear your browser cache if the issue persists.

If you need assistance testing your website or have questions about the migration process, our support team is available 24/7. Visit our contact page or email us at support@obhost.org for help.


Was this answer helpful?

« Back