How to view your website on the new server before changing the DNS

Make your computer open the domain on our server while everyone else still sees it on the old hosting. Ideal for developers and migrations.

Basic concepts

How does it work?

When you type a domain in your browser, your computer asks the DNS which IP address it has. As long as the domain's DNS points to the external hosting, everyone will end up there.

Before asking the DNS, however, your computer checks a local file called hosts. If you write the domain there with our server's IP, your computer (and only yours) will go straight to the new server. Nothing changes for anyone else, and you undo it by deleting the line.

Website migration

The website is still running on the old hosting and you want to check it on our server before the final switch.

Development

You're building the new website and need to work on it with the real domain, without the public seeing it yet.

Testing before the switch

You want to check that everything works (forms, emails, payments) before changing the DNS, so there are no surprises.

Before you begin

What you need

1

Your server's IP

You'll find it in the control panel (control.intergrid.cat), on the hosting's page. If you can't find it, ask support.

2

The domain, with and without www

They are two different names: add both, plus any subdomain you want to test.

3

Administrator rights

The hosts file belongs to the system: you need to be an administrator of the computer to save it.

The examples use the following IP and domain. Replace them with yours:

203.0.113.10 elteudomini.cat 203.0.113.10 www.elteudomini.cat
Step by step

Edit the hosts file

Windows

  1. Open the Start menu, type Notepad, right-click it and choose Run as administrator.
  2. In Notepad, go to File > Open and paste this path (choose «All files» so it shows up):
    C:\Windows\System32\drivers\etc\hosts
  3. Add the lines at the end of the file and save it.
  4. Clear the DNS cache: open Command Prompt and run:
    ipconfig /flushdns

macOS

  1. Open Terminal (Applications > Utilities) and edit the file:
    sudo nano /etc/hosts
  2. Type your Mac password, add the lines at the end and save with Ctrl+O, Return and Ctrl+X.
  3. Clear the DNS cache:
    sudo dscacheutil -flushcache sudo killall -HUP mDNSResponder

Linux

  1. Edit the file as administrator:
    sudo nano /etc/hosts
  2. Add the lines at the end and save.
  3. If you use systemd-resolved, clear the cache:
    sudo resolvectl flush-caches
The browser

If the browser still shows the old website

Chrome, Edge, Brave

Browsers keep addresses for a few minutes. Open these pages and press the buttons to clear them:

chrome://net-internals/#dns → Clear host cache chrome://net-internals/#sockets → Flush socket pools

In Edge, replace chrome:// with edge://.

Firefox

Open this page and press the button to clear the DNS cache:

about:networking#dns → Clear DNS Cache

Secure DNS (DNS over HTTPS)

If the browser has secure DNS enabled in strict mode, it may skip the hosts file. Turn it off while you test:

  • Chrome: Settings > Privacy and security > Security > Use secure DNS.
  • Firefox: Settings > Privacy & Security > DNS over HTTPS > Off.

Close and reopen the browser if needed, or try it in a private window: that way the page cache won't fool you.

Checking

How to tell you're seeing the new server

From the terminal

Ping the domain: our server's IP should reply.

ping elteudomini.cat

Note: nslookup and dig ask the DNS directly and ignore the hosts file, so they will keep showing the old IP. That's normal.

From the browser

Open the developer tools (F12), go to the Network tab, reload the page and click the first request: «Remote Address» should show our server's IP.

Compare it with what everyone else sees

The domain diagnostic queries public DNS from our servers, not from your computer: it gives you the A record IP that everyone else sees. Before the switch it should show the old hosting's IP; if your browser shows ours, the hosts file is working.

After changing the DNS, check again: once it shows our server's IP, you can delete the lines from the hosts file.

Open the domain diagnostic →

For developers

Without touching the hosts file

curl

To test a specific request without changing anything on your system:

curl -I --resolve elteudomini.cat:443:203.0.113.10 \ https://elteudomini.cat/

A separate Chrome window

Open Chrome with a temporary profile where the domain goes to the new server. Your other windows are not affected:

# macOS open -na "Google Chrome" --args \ --user-data-dir=/tmp/chrome-proves \ --host-resolver-rules="MAP elteudomini.cat 203.0.113.10, MAP www.elteudomini.cat 203.0.113.10" # Windows "C:\Program Files\Google\Chrome\Application\chrome.exe" ^ --user-data-dir=%TEMP%\chrome-proves ^ --host-resolver-rules="MAP elteudomini.cat 203.0.113.10, MAP www.elteudomini.cat 203.0.113.10"
Best practices

Important notes

Delete the lines when you're done
Once the DNS points to the new server, remove the lines from the hosts file. If you leave them and the IP changes one day, your computer will keep going to the old address without warning.
Certificate warning (HTTPS)
Until the DNS points to our server, the free Let's Encrypt certificate can't be issued yet, and the browser may say the connection isn't secure. You can continue just for testing, or use http://. The certificate is issued automatically once the DNS changes.
Websites that redirect to their own domain
WordPress, PrestaShop and other applications redirect to the address they are configured with. That's why it's better to test them with the real domain and the hosts file, not with the IP or a temporary address.
What about mobile?
On phones you can't edit the hosts file without special tools. Do your testing from a computer.
Email doesn't change
The hosts file only affects what your computer does. Email that others send you keeps arriving wherever the DNS says until you change it.
Need help?

If you don't know which IP to use or the website doesn't look as expected, our support team will help you.

 Create support ticket