Share via


Listening to port 80 without being admin

If you're writing integration or so called end-to-end tests for web services you typically need to spin up a service locally just for a few tests. Or maybe you're just interested in doing some manual testing locally. In both cased you likely need to be an administrator to be able to listen to the desired port and/or URL prefix (I'm assuming HTTP here). Or you need to configure HTTP.sys to allow you to listen to the desired prefix without running as an administrator. Both options are bad. Relying on configuration is always a pain and running as administrator is typically a bad idea since your service most likely will not once deployed. There is however a third option that is kind of a cheat on the configuration approach. For a few versions of windows (I honestly don't know when it started, but was in Vista and is still in Win8 beta) there has been a preconfigured HTTP prefix for this exact purpose, i.e. spinning up a temporary listener.

If you run: "netsh http show urlacl" from a command prompt you'll notice this one: https://+:80/Temporary_Listen_Addresses/.

The only thing you need to think about in order to use this is to make sure you can easily configure your service to use this HTTP prefix for whatever it does. And having a test configuration you probably need anyway so this shouldn't be too much of a problem. And you don't have to configure HTTP.sys and can run your tests as a regular user rather than an admin.