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.
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.
What you need
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.
The domain, with and without www
They are two different names: add both, plus any subdomain you want to test.
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:
Edit the hosts file
Windows
- Open the Start menu, type Notepad, right-click it and choose Run as administrator.
- In Notepad, go to File > Open and paste this path (choose «All files» so it shows up): C:\Windows\System32\drivers\etc\hosts
- Add the lines at the end of the file and save it.
- Clear the DNS cache: open Command Prompt and run: ipconfig /flushdns
macOS
- Open Terminal (Applications > Utilities) and edit the file: sudo nano /etc/hosts
- Type your Mac password, add the lines at the end and save with Ctrl+O, Return and Ctrl+X.
- Clear the DNS cache: sudo dscacheutil -flushcache sudo killall -HUP mDNSResponder
Linux
- Edit the file as administrator: sudo nano /etc/hosts
- Add the lines at the end and save.
- If you use systemd-resolved, clear the cache: sudo resolvectl flush-caches
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:
In Edge, replace chrome:// with edge://.
Firefox
Open this page and press the button to clear the 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.
How to tell you're seeing the new server
From the terminal
Ping the domain: our server's IP should reply.
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.
Without touching the hosts file
curl
To test a specific request without changing anything on your system:
A separate Chrome window
Open Chrome with a temporary profile where the domain goes to the new server. Your other windows are not affected:
Important notes
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.
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.
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.
On phones you can't edit the hosts file without special tools. Do your testing from a computer.
The hosts file only affects what your computer does. Email that others send you keeps arriving wherever the DNS says until you change it.