Edit the hosts file to open your new hosting
Short answer
Add one line to your computer’s hosts file: your new hosting’s IP address, then your domain. Then only your computer opens the new hosting, until you remove the line again.
- Result
- Your domain opens the new hosting
- Your time
- About 5 minutes
- Cost
- Free
- Your visitors
- Still see the old site
Which way fits you?
- Windows 10 and 11With Notepad, started as administrator.
- MacIn Terminal, with your Mac password.
- LinuxIn a terminal, with sudo.
Before you start
- A computer. Phones need extra apps for this.
- Administrator rights on it, or your Mac password.
- Your new hosting’s IP address and your domain.
Check first: this way opens your domain with http://. For some domains, browsers refuse that. The wp2wp.link guide checks your domain and only suggests this way when it works. Otherwise use your new host’s temporary address, or ask its support for one.
Your line for the hosts file
The line is the IP address, a space, your domain, a space, and your domain with www:
203.0.113.10 your-domain.com www.your-domain.com
The IP address is your hosting’s number, four groups of digits. You find it in your new host’s control panel:
- cPanel: in the General Information box on the right, as Shared IP Address or Dedicated IP Address.
- Plesk: Websites & Domains, your domain’s hosting settings.
- SiteGround: Site Tools, Dashboard, IP and Name Servers.
- Other hosts: look for “server IP”, “shared IP” or “IP address” in the hosting overview or the welcome email. Or ask support.
Windows 10 and 11
You edit the file in Notepad. Notepad needs administrator rights for this.
In the Start menu, type Notepad.
Right-click Notepad and choose Run as administrator.
Windows asks for permission: click Yes.
Choose File → Open, paste this path as the file name and click Open.
C:\Windows\System32\drivers\etc\hostsAdd your line at the very end, on its own line, and choose File → Save.
In the Start menu, type cmd and open Command Prompt.
Enter
ipconfig /flushdns.This makes Windows forget the old address.
Mac
You edit the file in Terminal with the nano editor.
Open Terminal in Applications → Utilities.
Type
sudo nano /etc/hostsand press Enter.Enter your Mac password. Nothing appears while you type; that’s normal.
Move to the end with the arrow keys and add your line.
Press Control+O and Enter to save.
Then press Control+X to close the editor.
Enter
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.This makes the Mac forget the old address.
Linux
You edit the file in a terminal with the nano editor.
In a terminal, run
sudo nano /etc/hosts.Add your line at the end.
Save with Control+O and close with Control+X.
Run
resolvectl flush-caches.This works on most current systems.
Open your domain
Warning in the browser: your browser may say the connection isn’t secure. That’s expected here, so continue to the site. If the warning offers no way to continue, remove the line and use a Temporary address Many hosts give a new hosting account an extra address. With it you can open the site before your own domain points there. instead.
Close your browser completely and start it again.
Browsers keep their own memory of addresses.
Type your address with
http://at the start.For example
http://your-domain.com/reprint-web.php.
Undo it afterwards
Once your domain points to the new hosting, remove your line. Then your computer finds your site the normal way again.
Open the Hosts file A small file on your own computer. It can point a domain to a server you choose, but only for your computer. the same way as before.
Delete your line and save the file.
Clear the cache again with the same command.
How you know it worked
- Your domain with
http://shows the new hosting, for example the helper’s login. - Everyone else still sees the old site until you switch the domain.
If something goes wrong
I still see the old site
Check the line for typos and make sure you saved the file. Then restart the browser.
It still shows the old site, and I use a VPN
A VPN can skip the hosts file. Turn it off while you work.
Windows says I don’t have permission to save
Notepad wasn’t started as administrator. Close it, right-click Notepad, choose Run as administrator, and open the file again.
Questions
Does this change anything for my visitors?
No. The hosts file only affects the computer it’s on. Everyone else keeps seeing the old site until you switch the domain.
Does it work on my phone?
Not without extra apps. Use a computer for this.
Why does the browser warn about the certificate when I check my copied site?
That’s expected before the switch. Your new host can only create the free SSL certificate (HTTPS) What makes your site open with https:// and a lock in the browser. Most hosts create one for free once your domain points to them. once your domain points to it. Continue to the site. The warning only affects your computer.
wp2wp.link walks you through the whole move and tells you whether this way works for your domain.
Start your moveFree · No account
Sources, checked 20 November 2026
Microsoft: ipconfig, Apple: reset the DNS cache, resolvectl, cPanel interface, SiteGround: hosts file, GoDaddy: preview your website, Chromium HSTS preload list.
Was this page helpful?
Thanks for letting us know.
Thanks for letting us know. What was missing or wrong? Write to benni@wp2wp.link, we read every message.