Skip to content
Which TLD to Use for Local Development (.test vs .localhost)

Which TLD to Use for Local Development (.test vs .localhost)

Updated 5 min read

Which TLD to use for local development: prefer .test, avoid .dev and .local. Why .test is reserved, how to map it in the hosts file, and HTTPS tips.

Use .test for local development. It is officially reserved by the IETF (RFC 6761) for testing, so it will never become a real public domain and cannot collide with a live site. Avoid .dev (a real Google-owned TLD that forces HTTPS) and .local (reserved for mDNS/Bonjour). The other safe reserved options are .localhost and .example.

Best TLDs for local development

TLDStatusUse for local dev?
.testReserved (RFC 6761)Yes, recommended
.localhostReserved (RFC 6761)Yes
.exampleReserved (RFC 6761)Yes (less common)
.devReal TLD, HSTS-preloadedNo, forces HTTPS
.localmDNS/BonjourNo, resolution conflicts
.appReal TLD, HSTS-preloadedNo

.test or .localhost?

Both are reserved and safe, so the choice depends on what you need:

.test.localhost
SetupA hosts entry or dnsmasqNone, browsers resolve it
Browser "secure context" over plain HTTP (service workers, clipboard, camera)No, needs HTTPSYes
Point a name at an IP other than 127.0.0.1YesNo
Works in command-line tools and runtimesYes, once mappedDepends on the tool
Shared cookies between subdomainsYes, with Domain=.myapp.testHard, see [[subdomains-on-localhost

Browsers treat localhost and *.localhost as secure contexts even over plain HTTP, which .test does not get. If your app uses an API that requires a secure context, either use .localhost or put HTTPS on your .test domain.

.test does not resolve on its own

Reserved does not mean pre-configured. RFC 6761 only guarantees that .test will never exist on the public internet, and it tells resolvers not to give it special treatment. A lookup for myapp.test goes to a DNS server, which answers that the name does not exist. That is why you must map the name yourself, in the hosts file or with dnsmasq, before it works.

Why .test wins

.test is guaranteed never to resolve on the public internet, so myapp.test always means "my local project." There is no risk that a colleague's typo leaks to a real site, and no browser HTTPS coercion.

Why avoid .dev and .app

Both are real TLDs on the HSTS preload list. Browsers force HTTPS on them, so a plain HTTP dev server at myapp.dev fails to load. If you need HTTPS locally, set it up deliberately with mkcert, see local HTTPS with mkcert.

Why avoid .local

.local is reserved for multicast DNS (Bonjour/Avahi). Using it for hosts entries causes slow lookups, intermittent failures, and conflicts with device discovery.

How to set up a .test domain

Add it to the hosts file and flush DNS:

127.0.0.1 myapp.test api.myapp.test
How many times will you retype this command this month?Automate it with ToggleHosts

See the hosts file syntax guide and, when done, flush DNS. For many dynamic subdomains (*.myapp.test), the hosts file cannot use wildcards, use dnsmasq, covered in wildcard local domains with dnsmasq.

Check that it resolves

Use a tool that goes through the same lookup your applications use:

dscacheutil -q host -a name myapp.test
# Windows (PowerShell)
[System.Net.Dns]::GetHostAddresses("myapp.test")

Do not use nslookup or dig for this. They query DNS servers directly and never read the hosts file.

Open it in the browser

Type the full address, http://myapp.test, rather than the bare name. Some browsers treat a bare unknown name as a search query. If the page does not load, the cause is usually the server, not the name: see localhost refused to connect.

Call it from a container

A container does not read your computer's hosts file. To let a container reach myapp.test, give it its own entry in Docker Compose:

services:
  api:
    extra_hosts:
      - "myapp.test:host-gateway"

host-gateway resolves to the host machine from inside the container.

When a service refuses .test

Some third-party services, OAuth providers among them, only accept redirect URLs on a public top-level domain or on localhost. A .test address can be rejected for that reason. Two ways around it:

  • Use localhost with a port for that one integration.
  • Use a wildcard DNS service such as nip.io or sslip.io, which resolves names like myapp.127.0.0.1.nip.io to 127.0.0.1. It depends on a third party and on internet DNS, so keep it for the cases that need it.

Naming conventions that age well

  • One domain per project: project.test, with services as subdomains such as api.project.test.
  • Never invent a name under a real domain you do not control, and avoid subdomains of your company domain for local work. A typo or a leaked cookie can reach a real system.
  • Write the names in the project README so the whole team uses the same ones. For a team workflow, see sharing hosts configurations.

Need subdomains under your .test domain? See how to use subdomains on localhost.

Manage them without editing files by hand

Juggling several .test domains across projects gets messy fast. ToggleHosts stores each mapping with a one-click toggle and flushes DNS automatically, so switching between projects is instant. To pick a hosts manager, the editor comparisons for Windows, Mac and Linux put the options side by side.

_Last reviewed: June 2026._

Sources and further reading

Frequently Asked Questions

Use .test. It is reserved by the IETF (RFC 6761) for testing and will never be a real public TLD, so it cannot clash with a live domain.

.dev is a real public TLD owned by Google and is on the HSTS preload list, forcing HTTPS in browsers. That breaks plain HTTP local sites.

No. .local is reserved for mDNS/Bonjour and can cause slow or failed resolution and conflicts on many systems.

Add a line to the hosts file: 127.0.0.1 myapp.test, then flush DNS. For many subdomains, use dnsmasq with a wildcard.

Related Articles

© 2026 ToggleHosts · All rights reserved[email protected]