Hosts file generator
Enter your domain and the new server’s IP to get the exact hosts file lines, with steps for Windows, macOS and Linux. Everything runs in your browser.
How it works
Your computer checks its hosts file before it asks DNS. A line such as 203.0.113.10 example.com sends every request for example.com from this computer to 203.0.113.10, so you can test a site on its new server before you change DNS. The generator writes the lines with a comment that marks them, so you can find and remove them later.
When to remove the lines
As soon as DNS points at the new server. Left in place, the entry keeps this computer on that IP even if the site moves again or the IP changes, and it hides DNS problems that your visitors would see.
The limits of a hosts file
The change works only on the computer where you made it, needs administrator rights, does not work on most phones and cannot be shared with a client. A DNSPeek preview link avoids all of that; see how the two compare on the hosts file alternative page.
Frequently asked questions
What does a hosts file entry do?
It tells one computer to use a fixed IP address for a domain instead of asking DNS. Pointing your domain at the new server’s IP lets you open the site on the new server from that computer while everyone else still reaches the old one.
Why does the browser still show the old site?
Browsers and the operating system cache DNS answers. Flush the DNS cache with the command shown for your system, close the browser completely and open it again. Also check that no VPN or secure DNS setting in the browser bypasses the hosts file.
Do I need the www line?
Add it if visitors use both example.com and www.example.com, or if the site redirects from one to the other. Each hostname needs its own line.
Is there a way without editing the hosts file?
Yes. A DNSPeek preview link shows the site on the new server through an ordinary HTTPS address, so it works on phones and for clients who cannot edit system files, and you can share it.
Moving a site to a new server?
See the site on the new server before you change DNS: DNSPeek gives you one HTTPS preview link that works on any device and that you can share with your team or client. No hosts file, no VPN.
Create a free preview link