How to preview your site before changing DNS
Two ways to check a site works before a domain change goes live, so the domain switch is the last step rather than the first.
The best time to find a problem with a website is before its domain is pointing at it, not after. Changing DNS commits the live domain to whatever is currently sitting in your hosting account, and if something is broken, visitors see it too. Previewing the site first means the DNS change becomes the last step of the launch instead of the first thing you test with.
Method 1: a temporary server address
Most hosting accounts can be reached by a temporary address before any domain is connected, shown in your control panel or welcome email — something like a shared server hostname with your account's folder appended. Loading that address shows exactly what your site currently looks like on the server, independent of any domain or DNS setting.
This address is specific to your hosting account and server. Always copy it from your own control panel or welcome email rather than guessing at a pattern — an address from a different account will simply show somebody else's site or an error.
This is the fastest option when it is available and needs no configuration on your part, but not every setup supports it cleanly, particularly for sites that check the requested domain name internally — some content management systems redirect based on the domain configured in their settings, which can undo the point of previewing altogether.
Method 2: edit your hosts file
A hosts file edit is the more reliable option, especially for WordPress and other systems that expect a specific domain. It works by telling your own computer — not the wider internet — to send requests for your domain straight to your hosting account's address, while everyone else's computer still sees wherever DNS currently points.
-
Find your hosting account's IP address
Shown in your control panel or welcome email. Copy it exactly.
-
Open your computer's hosts file
On Windows, this is
C:\Windows\System32\drivers\etc\hosts, edited with a text editor run as administrator. On macOS or Linux, it is/etc/hosts, edited withsudo. -
Add a line pointing your domain at that address
The format is the IP address, a space, then the domain: for example
203.0.113.10 yourdomain.com. Add a second line forwww.yourdomain.comif you need that version too. -
Save the file and flush your DNS cache
On Windows,
ipconfig /flushdnsin Command Prompt. On macOS,sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. -
Load the domain in a browser
It should now show the site sitting in your hosting account, even though public DNS for the domain has not changed at all.
A hosts file entry overrides DNS permanently on that one computer until you delete it. Once you have gone live and pointed the domain properly, take the line back out — otherwise your own machine will keep showing an old version of the site if you ever move hosting again, long after everyone else sees the current one.
What to actually check while previewing
- Every page loads without errors, not just the homepage.
- Forms submit correctly, including anything that sends an email or writes to a database.
- Images, styles and scripts all load rather than showing as broken links, which sometimes happens when a site references its old domain directly instead of a relative path.
- Any SSL certificate is in place and working, so the site is not throwing a security warning the moment it goes live.
Troubleshooting: the preview is not showing what you expect
| What you see | Likely cause | What to do |
|---|---|---|
| The temporary address shows an error or a default page instead of your site | The site is not installed in the folder the temporary address points to, or DNS on your account has not caught up with a very recent change | Confirm the site files are in the right folder in your control panel, and check the temporary address is copied exactly as shown |
| A hosts file entry has no effect at all | The DNS cache was not flushed after saving the file, or the file was not saved with administrator/root permissions | Flush the DNS cache and reopen the browser; confirm the hosts file save was not silently blocked by permissions |
| The site keeps redirecting to the live domain | The application stores its own domain internally and redirects any other request to it | Check the site's own settings for a hardcoded site URL, or preview using the temporary address instead if the platform supports it cleanly |
| Some pages work but others 404 | Permalink or routing rules tied to the live domain, or a caching layer still serving old results | Clear any site-level cache and check routing settings are not domain-specific |
| The browser still shows an old version after removing a hosts entry | Your browser's own cache, not DNS or the hosts file, is serving a stored copy | Clear your browser cache — see the guide linked below |
Letting someone else preview the site too
A hosts file entry only affects the one computer it was added to, which is fine for testing alone but a limitation the moment a client, colleague or designer needs to see the same preview. The temporary server address from Method 1 works for anyone, provided the site does not depend on checking its own domain internally. If it does, the practical options are either walking the other person through adding the same hosts file entry on their own machine, or waiting until DNS is pointed and reviewing the finished site live instead — both reasonable depending on how much of a hurry the review is in.
Once the preview looks right
With the site confirmed working, follow pointing a domain to your hosting to make the change public. Because you have already tested the site itself, the only thing left to watch is DNS spreading across the internet — which is a waiting problem, not a debugging one.
If a browser is still showing an old version of the site after you remove a hosts file entry or after DNS has changed, clear your browser's cache before assuming something is wrong — see clearing your browser cache.
Frequently asked questions
Can I preview a site on my phone before DNS changes?
Not with a hosts file edit in most cases, since editing the system hosts file on a phone generally needs extra software or a jailbroken or rooted device. The temporary server address is the practical option for mobile preview, provided the site does not check the requested domain internally. If it does, testing on a computer with a hosts file entry is the more reliable route.
Why does my site redirect to the live domain even with a hosts file entry?
Some content management systems store the site's domain in their own configuration and redirect any other request to it, regardless of what your browser thinks it is connecting to. A hosts file entry controls where your computer sends the request, not what the application does once it receives it, so this kind of redirect will override your preview.
Do I need to tell my host I am previewing a site this way?
No. Both methods only involve your own computer and settings that are already available to you — the temporary address is provided for exactly this purpose, and a hosts file edit happens entirely on your own machine.
Related reading
One edit on your own computer lets you load the new server privately while every other visitor keeps seeing the old one.
How to point a domain to your hostingThe two ways to connect a domain to a hosting account, when to use each, and how to tell the change has actually taken effect.
How to upload your first websiteTwo ways to get your files onto your hosting account, which folder they belong in, and how to tell the upload actually worked.
How to clear your browser cache properlySupport will often ask for this first, because a stale cached copy of a page is a surprisingly common cause of a fault that has already been fixed.