Skip to main content

The mysterious .dev.localhost checkbox

When you create a new ASP.NET Core project in Visual Studio, there's a checkbox that's easy to click past: "Use the .dev.localhost TLD in the application URL." I always want to understand what a checkbox actually does before I tick it, so let's dig into this one.

The problem it solves

When you're working on more than one local web project, they all end up living at the same address: localhost. Only the port number tells them apart. Open your browser's address bar with three projects running and you'll see localhost:5001, localhost:5215, localhost:7099 — and you have no idea which is which until you actually look at the page.

There's a second, less visible issue: because everything shares the localhost name, cookies and other domain-scoped browser storage are also shared across all your local apps. That's not something you usually want when you're testing.

What .dev.localhost actually is

.localhost is a reserved top-level domain, defined in RFC2606 and RFC6761 specifically for local testing. Modern browsers already resolve anything ending in .localhost straight to the loopback address (127.0.0.1/::1), so myapp.localhost behaves exactly like localhost without any hosts file editing or DNS setup.

Starting with .NET 10, ASP.NET Core builds on this and adds first-class support for a .dev.localhost subdomain. The project templates for ASP.NET Core Empty and Blazor Web App can combine your project name with that suffix, so instead of:

https://localhost:7099

you get:

https://myapp.dev.localhost:7099

That's the checkbox. It's also available from the CLI if you're not going through the Visual Studio wizard:

dotnet new web -n MyApp --localhost-tld

Remark: Kestrel is aware of .localhost addresses specifically. When your launch profile or ASPNETCORE_URLS points to a .dev.localhost name, Kestrel binds to the loopback address only (127.0.0.1/::1), not to all interfaces. It also logs both the .localhost and plain localhost addresses on startup, so you know both still work.

Why enable it

  • You can actually tell your apps apart. The project name is right there in the address bar instead of a port number you have to memorize.
  • Cookies and storage stop colliding. Because each app gets its own subdomain, browser storage that's scoped to the domain no longer bleeds between your local projects.
  • HTTPS still works out of the box. The ASP.NET Core dev certificate already lists *.dev.localhost as a Subject Alternative Name. You don't need to generate anything extra — dotnet dev-certs https already covers it. A wildcard cert for *.localhost itself isn't valid for a top-level domain, which is exactly why the .dev subdomain exists.
  • Nothing breaks. Kestrel keeps listening on plain localhost at the same time, so tools or scripts that still call localhost:7099 keep working.

The one gotcha: Safari

Safari on macOS doesn't resolve *.localhost names automatically. If you're testing in Safari, fall back to the plain localhost address — it's still there, side by side with the .dev.localhost one.

The same applies to non-browser clients. Some HTTP clients and tools resolve .localhost names through the normal DNS stack instead of special-casing them, and if your DNS doesn't know what to do with them, the request just fails. For those cases, keep using regular localhost.

That's it! A small checkbox, but now you know exactly why it's there — and when to leave it unchecked.

More information

Popular posts from this blog

Podman– Command execution failed with exit code 125

After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

Cache stampede: when our cache turned against us

While investigating some performance issues, we ran into an ASP.NET Core API that cached a fairly expensive aggregation query for 60 seconds. Under normal load, that was fine: one request rebuilds the cache, everyone else reads from it. Under peak load, dozens of requests would arrive in that same expiry window, all see a cache miss, and all fire the same expensive query in parallel. The database didn't like that. That was the moment when our caching layer stopped helping and started hurting. A burst of requests comes in at the same time, all miss the cache, and all go hammer the database or the downstream API at once. That's a cache stampede . The cache was supposed to protect our backend, and for a few hundred milliseconds it did the opposite. Why this happens IMemoryCache.GetOrCreate (and its async sibling) looks like it protects you, but it doesn't add any locking on its own. Look at the naive version: public async Task<Report> GetReportAsync(string key) ...

A complex system designed from scratch never works

A few years ago, I worked as an architect on a big mainframe rewrite. I still count it as one of my failures. Not because the technology was wrong, but because I couldn't convince the management team to simplify the approach. Years later, the organization is still struggling to get the new system up and running. I left the project at the time, because I couldn't put my name behind an approach that would take very long and cost a lot of money without a working system to show for it along the way. Gall’s Law That memory keeps coming back to me, because it's a textbook case of Gall's Law playing out in real life. Gall's Law , from John Gall's Systemantics , states it plainly: A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works, and it cannot be patched to make it work. You have to start over with a simple system that works. What does that mean in practice,...