Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Windows Service that uses a WCF service host to listen for connections on TCP port 61000. When I try to start the service, I get the error:

Service cannot be started. System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL http://+:61000/ because TCP port 61000 is being used by another application. ---> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process
   at System.Net.HttpListener.AddAll()
   at System.Net.HttpListener.Start()
   at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
   at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)

A quick netstat -a shows there is nothing listening on port 61000. I've also found several posts online that mention reserving namespaces using netstat, but the account that the service runs under has administrator privileges so that shouldn't be necessary.

Any other ideas as to why I'm getting this message?

This service is running on 64-bit Windows Server 2008 R2 Standard.

share|improve this question
What happens if you telnet to port 61000? Any reply? – AliGibbs Feb 15 '11 at 19:33
@Ali - alright this is weird, after restarting the server, the service started just fine and it's now listening on 61000 as designed. I tried a telnet localhost 61000 when it wasn't working before and received a "could not connect to host" error. I'm still wondering how a port could already be in use if netstat says otherwise! – John Rasch Feb 15 '11 at 19:55
Wierd but hopefully resolved :) – AliGibbs Feb 15 '11 at 20:46
reboot a day keeps dr watson away. – The Unix Janitor Jul 26 '12 at 14:48

If there was an open connection on the port when the program was closed, and TCP didn't complete the 4-way close handshake, then the socket will remain "half-closed" until the timeout has expired (even though the program has terminated), and will prevent you from opening that port again. Various implementations have different timeouts usually ranging from 1/2 second to 2 minutes.

share|improve this answer

Your Answer


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.