Speeding up localhost in Visual Studio

I recently put a new SSD in my system (yay!) and did a clean install of Windows 7, Visual Studio, etc. I found that when viewing my web app on localhost (using the Cassini web server built into VS), it was very slow. This was true across browsers.

Turns out it’s a DNS thing — the lookup for “localhost” was apparently going out to the DNS server, a waste. You can easily “short-circuit” this by modifying your hosts file. It’s in the C:\Windows\System32\drivers\etc folder.

Simply un-comment the localhost entry at the bottom of that file, like so: `# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost

::1 localhost`

It made things lickety-split for me.

Tip: you’ll need to run Notepad as an administrator to modify the file.

Published December 16, 2009