Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
add comment

migrated from stackoverflow.com May 14 '10 at 22:27

This question came from our site for professional and enthusiast programmers.

2 Answers

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.

share|improve this answer
1  
Don't forget to flip it off Automatic. Manual might be better if you want your service to work the next time you reboot. –  Chris May 13 '10 at 1:22
add comment
up vote 2 down vote accepted

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)

share|improve this answer
    
Windows Server 2008 doesn't have the program httpcfg.exe, how can achieve the same result on Windows Server 2008 ? –  aleroot Oct 14 '11 at 15:20
    
@aleroot - the program httpcfg.exe doesn't come in Windows Server 2003 either. As my answer suggests, I had to download it from a windows XP Support Tools package. I don't know if it will be compatible with Server 2008 though. –  Miky Dinescu Oct 21 '11 at 16:18
    
for Win2008r2, use the netsh utility to add your server to the http.sys system, as long as you have different urls, it can serve both servers on port 80. I think you want this: add urlacl url=http://+:80/MyUri user=DOMAIN\user –  gbjbaanb Jan 27 '12 at 14:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.