The Windows hosts file maps a hostname to an IP address on your own computer. This is useful for testing a website on a new server before changing public DNS during a migration.

Edit the hosts file

These steps use Windows 11. You need administrator permission.

  1. Keep a backup of the current hosts file.

  2. Search for Notepad in the Start menu, right-click it and choose Run as administrator.

  3. Select File > Open, browse to C:/Windows/System32/drivers/etc and change the file filter to All Files.

  4. Open the file named hosts, which has no filename extension.

  5. Add an entry using the new server’s actual IP address and the exact hostnames you want to test:

    203.0.113.10 example.com www.example.com

    203.0.113.10 is a documentation example, not a server you should use.

  6. Save the existing file without adding .txt to its name.

  7. If Windows retains an earlier answer, open an administrator Command Prompt and run:

    ipconfig /flushdns
  8. Reopen the browser and test the website using its normal domain name.

Check the test results

The entry affects this computer, not visitors or public DNS. Add each required hostname separately because the file does not support wildcard hostnames.

Browser caches, proxies and application-specific name resolution can affect testing. HTTPS still needs a certificate valid for the hostname, and redirects to another hostname need their own mapping if they should also reach the test server.

Remove the override

Delete the added line or place # at its start, then save the file. Flush the local DNS cache and restart the browser if needed. Remove temporary entries after testing so the computer does not continue using an old server address.