
Test a WordPress Site Before DNS Propagation
Preview and test a WordPress site on a new server before DNS propagation using the hosts file. Map your real domain to the new IP, verify, then switch DNS safely.
Manage hosts files without the terminal
ToggleHosts helps you manage environments visually on Windows, macOS, and Linux, with automatic DNS flush and backups.
One-time payment
To test a WordPress site before DNS propagation, map the real domain to the new server’s IP in your hosts file. Your computer then loads the new server using the live domain name, while everyone else still sees the old site. This is the safest way to verify a WordPress migration with the real URL, no database edits, no downtime.
How to test WordPress before DNS propagation
- Get the new server’s IP address from your host.
- Open the hosts file and add the domain (and www):
203.0.113.50 example.com www.example.com- Save the file, see edit the hosts file on Windows or on Mac.
- Flush DNS so the change applies, on Windows or on Mac.
- Open
https://example.comand test pages, login, checkout, and media. - When everything works, change the real DNS at your registrar, then remove the hosts entry and flush DNS again.
Why the raw IP does not work for WordPress
WordPress hard-codes the site address in the database (siteurl and home in wp_options). If you visit the new server by IP, WordPress redirects you back to the live domain, so you end up testing the *old* server. Mapping the real domain in the hosts file makes WordPress serve the new server under its own URL, exactly as it will after the switch.
Some installs also pin the URL with the WP_HOME and WP_SITEURL constants in wp-config.php. The hosts file method works either way: because you keep the real domain for the whole staging test, there is no constant to change and no temporary URL to search-replace.
Verify you are hitting the new server
nslookup example.comIt should return the new IP from your machine only. You can also drop a temporary marker file on the new server and confirm it loads. For a deeper checklist, see test a website before DNS migration.
Clean up after go-live
Leftover migration entries are the #1 cause of "I see the old site" confusion later. After DNS is switched, delete the temporary line and flush DNS so you resolve through real DNS like your visitors.
Make migrations painless
Editing the hosts file by hand for every client migration is error-prone, wrong IP, forgotten www, or a stale entry left behind. ToggleHosts keeps migration entries in a separate environment you can toggle on for testing and off after go-live, and it flushes DNS automatically, so WordPress cutovers stay clean.
_Last tested: June 2026 on Windows, macOS and Linux._
Sources and further reading
- Official WordPress documentation
- How DNS works (Cloudflare Learning)
- The hosts file explained (Wikipedia)
Frequently Asked Questions
Add a line to your hosts file mapping the real domain to the new server IP (e.g. 203.0.113.50 example.com www.example.com), flush DNS, then open the site. Your machine reaches the new server while the rest of the world still sees the old one.
WordPress stores the site URL in the database (siteurl/home), so visiting the raw IP usually redirects you back to the live domain. Mapping the real domain in the hosts file avoids that.
No. The hosts file method lets you preview with the real domain without touching wp_options, so no temporary URL changes or search-replace are needed.
Update DNS to the new server, then remove the temporary hosts entry and flush DNS so you follow real propagation like everyone else.
Related Articles
Migrate WordPress to a New Server With No DowntimeWordPress
Migrate WordPress to a New Server With No Downtime
3 min read
Fix WordPress Redirecting to the Live SiteWordPress
Fix WordPress Redirecting to the Live Site
3 min read
Fix ERR_TOO_MANY_REDIRECTS with Hosts File (2026)Troubleshooting
Fix ERR_TOO_MANY_REDIRECTS with Hosts File (2026)
3 min read