On Windows 11 and Windows 10, you can map a test hostname to your own PC by opening Notepad as administrator, editing the Windows hosts file, and adding a line such as 127.0.0.1 myapp.test. Windows can then resolve that name to its IPv4 loopback address instead of asking DNS for it. Verify the mapping with ping -4, and remove the line when testing is finished. The hosts entry does not start a web server or configure a site.

Windows shows myapp.test mapped to 127.0.0.1, successfully pinged, and open in a browser as a local development site. Before you edit the hosts file​

You need:

  • An administrator account, or administrator credentials that can be supplied at the User Account Control prompt.
  • A test hostname. This guide uses myapp.test; replace it consistently with the name your project uses.
  • If you want to open a website rather than just test name resolution, a local web application already running on this Windows PC, with its listening port known.

The .test domain is reserved for testing. It is a safer example than a real company or public domain, because a hosts entry can redirect requests for a real name away from its normal destination. On a work or school PC, check with your administrator before changing the file; an existing entry may be needed by organizational software.

The procedure is the same on Windows 11 and Windows 10. Microsoft ended general support for Windows 10 on October 14, 2025; eligible devices may receive security updates through an Extended Security Updates program.

A hosts-file mapping applies to the Windows installation where you make the change. It does not change your router, publish a DNS record, or automatically configure another computer, phone, virtual machine, or container.

Add the test-domain mapping​

Warning: The hosts file affects name resolution for software on this PC. Changing or removing an existing entry can interrupt access to a website or network service. Keep the existing content intact, and add only the test entry you intend to use.

  1. Make a backup. Open File Explorer and enter this path in the address bar:
    %WinDir%\System32\drivers\etc
    Copy the file named hosts and paste the copy somewhere convenient, such as your desktop. This gives you a reference for the original content. The active file is normally located at C:\Windows\System32\drivers\etc\hosts and has no file extension.
  2. Start Notepad with administrator permissions. Open Start, type Notepad, right-click the Notepad result, and select Run as administrator. Approve the User Account Control prompt or enter administrator credentials if requested.
    Opening the file in an ordinary Notepad window is not enough: you may be able to read it but unable to save changes to the protected folder.
  3. Open the active hosts file. In the elevated Notepad window, select File > Open. Enter the following path in the File name box and select Open:
    %WinDir%\System32\drivers\etc\hosts
    If you browse to the folder instead, change the file-type filter from *Text Documents (.txt) to All Files (.)** so the extensionless hosts file is visible. Open hosts, not hosts.txt or lmhosts.sam.
  4. Check for an existing entry for your test name. Use Edit > Find, search for myapp.test, and inspect any matching lines. Lines beginning with # are comments rather than active mappings.
    If an active entry already maps that name, do not add a competing entry. Determine why it is there before changing it, or choose a different test name. Leave unrelated entries and comments as they are.
  5. Add the mapping on a new line at the end of the file:
    127.0.0.1 myapp.test
    There must be at least one space or tab between the IP address and the hostname. Do not put # at the start of this line, and do not include http://, a port number, or a path in the hosts file.
    127.0.0.1 is the IPv4 loopback address: connections to it go back to the same machine. The entry is for the exact hostname myapp.test; it does not automatically add [www.myapp.test](http://www.myapp.test) or other subdomains.
  6. Save the file. Select File > Save, then close Notepad. If Notepad asks you to choose a new filename rather than saving the existing file, stop and check that you opened the active hosts file in an administrator window. Do not save a replacement as hosts.txt.
  7. Refresh the Windows resolver cache. Open Start, type Command Prompt, and open it. Run:
    ipconfig /flushdns
    A successful command reports that the DNS Resolver Cache was flushed. This clears cached resolver data so you can test the current configuration. You do not normally need to restart Windows.

The hosts line supplies a name-to-address mapping only. It does not choose a web port, set up a virtual host, or create an HTTPS certificate.

Verify Windows resolves the name to localhost​

  1. In Command Prompt, run:
    ping -4 myapp.test
  2. Look at the first line of output. It should identify myapp.test with the address 127.0.0.1, for example:
    Pinging myapp.test [127.0.0.1] with 32 bytes of data:
  3. Press Ctrl+C if you want to stop the test before it finishes.

The important result for this task is the address in brackets. If it is 127.0.0.1, Windows resolved the name to the intended IPv4 loopback address. A ping response does not prove that a website is running, and a ping failure alone does not necessarily prove that name resolution failed.

Do not use nslookup myapp.test as the deciding test for a hosts entry. Microsoft documents that nslookup queries DNS rather than demonstrating the normal hosts-file resolution path, so its answer can differ from the address used by Windows applications.

Check the local website, if you have one​

  1. Start your local application using its usual development command or tool. Confirm which HTTP port it reports.
  2. In a browser on the same Windows PC, enter the test hostname with that port. For example, if the application listens on HTTP port 5000, enter:
    [url]http://myapp.test:5000/[/url]
    Use your application’s actual port; 5000 is only an example. The port belongs in the browser address, not the hosts file.
  3. Check that the page or response is the one served by your local application.

If the name resolves correctly but the browser cannot connect, the mapping has done its part. Check whether the application is running, listening on the expected port and IPv4 loopback, and configured to accept requests for myapp.test. Some servers select a site or reject requests based on the requested hostname.

Troubleshoot the mapping​

  • Notepad reports access denied or cannot save. Close the file, launch Notepad using Run as administrator, and open the active hosts file from that elevated window. If you cannot approve elevation, ask the PC administrator. On a managed device, do not disable security controls or change file permissions merely to force the edit.
  • The hostname resolves to the wrong address. Reopen the active file and check the spelling, the 127.0.0.1 address, and whether the line starts with #. Search for other active lines containing the same hostname. Resolve any conflict only after understanding why the existing entry is there; otherwise use a different test hostname. Save, run ipconfig /flushdns, and repeat ping -4.
  • The entry looks correct, but Windows cannot find it. Check that the edited file is %WinDir%\System32\drivers\etc\hosts, not a desktop backup or a file called hosts.txt. Open it again from elevated Notepad to confirm the line was saved. Also make sure the hostname in the command is exactly the one in the file.
  • ping -4 works, but the browser shows the wrong site or no site. Verify the application’s port and hostname settings. A server may return a default site when it does not recognize the requested host. A proxy, VPN, browser setting, or application-specific resolver can also cause a particular application to behave differently from the Windows resolution test. Check the relevant configuration before changing it, especially on a managed PC.
  • The browser reports an HTTPS certificate warning. A hosts entry does not make a certificate valid for myapp.test. Use the project’s correctly configured development certificate for that hostname, or use the application’s HTTP endpoint if appropriate for the test. Do not bypass a certificate warning for a real or sensitive service.
  • Another device cannot reach the test name. This hosts edit is local to the Windows PC. Also, 127.0.0.1 on another device points back to that device, not to your Windows PC. Access from another device requires a different network and server configuration; copying this loopback entry there will not accomplish it.
  • IPv6 behaves differently. This guide adds an IPv4 mapping only. ping -4 deliberately tests that mapping. If an application also uses IPv6, check its configuration and any existing entries rather than disabling IPv6 or adding a second mapping without knowing that the local service accepts it.

Remove the mapping after testing​

Warning: Remove only the line you added. Replacing the whole hosts file with a default or an old backup can erase other mappings that software or your organization now needs.

  1. Start Notepad using Run as administrator again.
  2. Select File > Open and open:
    %WinDir%\System32\drivers\etc\hosts
  3. Find the line you added:
    127.0.0.1 myapp.test
    Delete that line. Alternatively, put # at its beginning to leave it in the file as an inactive comment. Do not alter unrelated lines.
  4. Select File > Save and close Notepad.
  5. In Command Prompt, run:
    ipconfig /flushdns
  6. Reopen the hosts file and confirm the line is gone or commented out. Then run ping -4 myapp.test again. If no other resolution source supplies the name, it should no longer resolve through the entry you removed. A .test name may fail to resolve after removal, which is expected unless your network has separately configured it.

If the name still resolves to 127.0.0.1, check for another active entry for the same hostname or a separate DNS configuration. If an application still behaves differently after the Windows check, close and reopen that application and review its own proxy or name-resolution settings. On an organization-managed PC, ask the administrator before removing entries you did not create.