Your computer's hosts file lets you override DNS for chosen domains on that one machine. It is the best way to test a migrated site on its real domain name, including SSL and absolute links, before you change nameservers for everyone.
Before you start
- Find your hosting IP address: open StackCP for the site and look in the account information panel on the right. You normally need the IPv4 address.
- You need administrator rights on your computer.
The line to add
Each entry is the IP address followed by every hostname you want to redirect, separated by spaces:
203.0.113.10 yourdomain.com www.yourdomain.com
Replace the example IP with your own. Include every version of the name you will visit, including www and any subdomains, or some requests will still go to the old server.
Windows 10 and 11
- Click Start and type Notepad.
- Right-click Notepad and choose Run as administrator.
- Choose File > Open and open
C:\Windows\System32\drivers\etc\hosts(set the file type filter to All Files). - Add your line at the bottom and save.
- Optional: open Command Prompt and run
ipconfig /flushdns.
macOS
- Open Terminal (Applications > Utilities).
- Run
sudo nano /etc/hostsand enter your Mac password. - Add your line, then press Control+O and Enter to save, and Control+X to exit.
- Clear the DNS cache:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Linux
- Open a terminal and edit the file with your preferred editor, for example
sudo nano /etc/hosts. - Add your line and save.
When you have finished
Remove or comment out the line (put # at the start) once testing is done. If you forget, your computer will keep using the address in the file even after the real DNS changes.
Tips
- Browsers keep their own DNS cache. If nothing changes, close and reopen the browser or try a private window.
- Secure DNS (DNS over HTTPS) in some browsers can ignore the hosts file. Turn it off temporarily if your test does not work.
Need help?
If anything here does not work as described, our team is happy to take a look. Open a support ticket from your client area or message us on WhatsApp at 01818160926.
Categories
Written by
FimuroHost Team
Technical Writer