How To View A New Website Using Your Hosts File

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

W H AT W E D O OUR CL IENT S OUR WORK WHO WE AR E BL OG CONT ACT

Wrong art icle? Ret urn t o Knowledge Base

How to view a new website


using your hosts file
Graham Bailey, Hosting

T ime to Read: 5 minutes Difficulty Level: Beginner

Tools Needed: text editor, Plesk control panel Last Updated:

WHY WOULD YOU NEED TO EDIT YOUR HOSTS FILE?


You’ll often want to preview or develop a site on your Nublue hosting that still points elsewhere, ie: a site that’s not yet live
with us. T his can be handy for viewing a site you’re working on, or even checking how a site that you have migrated to a
new server looks before setting it live.

Getting started
Windows users

Mac users
Reversing the change

GETTING STARTED
T he best method is to use your computer’s hosts file to bypass the usual DNS lookup. T his forces your machine to view
the domain on the IP address that you specify. It will only work for your computer, so all other users will see the live version
of the site. Similarly, if you make this change on your phone, other machines and devices on your network remain
unaffected so you’ll still be able to view your live site on your smartphone.

WINDOWS USERS
In Windows 10 the hosts file is located at c:\Windows\System32\Drivers\etc\hosts.

Right click on Notepad in your start menu and select “Run as Administrator”. T his is crucial to ensure you can make the
required changes to the file.

Now click File > Open and browse to : c:\Windows\System32\Drivers\etc\hosts. If you can’t view any of the listed
directories you will need to configure Windows to show your hidden program or System Files as per the guide here.

Add a line to the bottom of the file the following lines, replacing IP_ADDRESS with the IP Address you took from the
Hosting Control Panel and DOMAIN_NAME with your domain:

IP_ADDRESS DOMAIN_NAME www.DOMAIN_NAME 

For example:

141.0.161.101 nublue.co.uk www.nublue.co.uk 

You’ll now need to save the file and you’re done. You should be able to visit your site and view it as it appears on the new IP
address. You may need to refresh your browser cache to ensure you’re seeing the new version of the site.
You can always test that you’re seeing the site on the IP you wanted by pinging your domain or by browsing to
https://your-domain-name.com:8443. T his will open up the Plesk control panel for your site and will show Nublue
branding if you’re seeing a version of the site hosted with us. You can also see the hostname of the server in the name of
the tab you’ve opened. T his can be very useful in confirming that you’re looking at the correct version of the site,
especially if both the old and new version of the site are hosted with Nublue.

MAC USERS
If you’re on a Mac, the changes you’ll need to make to your hosts file are identical but the process for editing the file is
different.

You can use the Terminal application to edit your hosts file. To do this, open up Finder then Applications > Utilities >
Terminal.

From here you can use the following command to edit your hosts file:

sudo nano /etc/hosts

You will have to supply your admin password for the Mac but you should be able to make any necessary amendments to
the hosts file. When you’re done, use Ctrl + O (followed by Enter) to save the file and then Ctrl + X to exit.

REVERSING THE CHANGE


To reverse the change and view the live version of your site again, you can simply remove the line you’ve added to your
hosts file and save it afterwards. If you’re going to be switching back and forth between viewing two versions of the site,
you can comment out the line with a leading “#” as in this example:

#141.0.161.101 nublue.co.uk www.nublue.co.uk 

T his allows you to add and remove the line easily in future, but bear in mind you may be seeing a cached version of the site
in your browser when you make the switch. If in doubt you can make sure you’re not viewing a cached copy of the site by
using a different browser, or switching to incognito/private mode. If this fails, you can refresh your browser cache or even
flush your machine’s DNS cache.

BACK T O KNOWL EDGE BAS E

LET'S    TALK
DIS C US S YOUR NE E DS W I T H A N E X PE RT 

CALL 0800 033 7074

GET IN T OUC H EC OMMERC E MA NA GED HOS T ING EXT RA S


S OL UT IONS HOS T ING
LAN MAN Domain Registration
Magento Cloud AWS Servers
SSL Certificates
4 Waterview,
White Cross, Lancaster, Shopify Magento AWS Servers
Lancashire, UK
LA1 4XS Shopware Clustered AWS Hosting

Development Retainers Ecommerce Calculator

Magento Commerce Hosting Guides


Email: hello@nublue.co.uk



© Nublue Ltd 2022 | Part of the CT I Group | Company Registration: 05523340 | VAT: 865693080

Privacy Policy | Terms & Conditions | SLA

You might also like