How to get a service to listen on port 80 on Windows Server 2003

I've coded a custom windows service that listens on TCP port 80 but when I try to install it on a Windows Server 2003 machine it fails to start because some other service is already listening on that port. So far I've disabled the IIS Admin service and the HTTP SSL service but no luck.

When I run netstat -a -n -o | findstr 0.0:80 it gives me the process id 4 as the culprit, but when I look at the running processes that process id points to the "System" process.

What can I do to get the System process to stop listening on port 80 and get my service to listen instead?

P.S. I should point out that the service runs fine if I install it on my Windows XP or Windows 7 development boxes. Also, I should specify that this has nothing to do with it being a service. I've tried starting a regular application that attempts to bind to port 80 on the Windows Server 2003 with the same outcome - it fails because another application is already bound to that port.


You want to stop the "World Wide Web Publishing Service".

By the way, the reason the port is actually opened by the 'System' process is because Windows Server 2003 moved parts of IIS into the kernel (specifically in the http.sys driver). This is so that things like static files can be served completely from the kernel (where the TCP/IP stack and filesystem drivers run) without a user-mode switch and provides better performance.


Thanks to some more digging I was able to find a solution to this problem. I was able to find the solution in part because of information provided by @codeka's answer.

To summarize, because Windows Server 2003 introduced a kernel mode driver (http.sys) to handle HTTP requests, I had to download a utility called HttpCfg.exe which comes in the Windows XP Support Tools and use it to instruct http.sys to stop listening for HTTP requests on port 80.

The command to do that was:

httpcfg.exe delete iplisten -i 0.0.0.0:80

After running that command, I used the query action to check that the address was indeed removed

httpcfg.exe query iplisten

And finally, I had to reboot the machine for the changes to take effect. After that I was able to create TCP sockets and bind to port 80.

As a side note, none of the other methods worked (i.e. disabling IIS Admin service, or the World Wide Web Publishing service, or the HTTP SSL service)

NOTE

Of course, the answer strictly refers to how to turn of the built-in mechanism available in Windows for processing HTTP requests via the kernel. It should be noted however that the kernel seems to provide a more efficient way to process HTTP requests than can be achieved in user mode. There are APIs available to leverage http.sys (kernel mode) HTTP processing of requests and I recommend exploring those if that's an option (i.e. unless you're just trying to run a service that's already built)