TCP Port sharing – Access is denied

I recently helped a customer who ran into this error:

System.ServiceModel.CommunicationException: The service endpoint failed to listen on the URI 'net.tcp://localhost/CalcultorService.svc/' because access was denied.  Verify that the current user is granted access in the appropriate allowAccunts section of SMSvcHost.exe.config. ---> System.ComponentModel.Win32Exception: Access is denied

They had updated the <allowedAccounts> section of the smsvchost.exe.config file as described here and then restarted the Net.Tcp port sharing service but still hit this error.  However, they didn't realize that there are additional services running inside of that same instance of the process.  The services that share the same process instance are: 

  1. Net.Tcp Listener Adapter
  2. Net.Tcp Port Sharing Service
  3. Net.Pipe Listener Adapter
  4. Net.Msmq Listener Adapter Correction:  I realized after posting this that the Net.Msmq service actually runs in different instance of SMSvcHost.exe, so you shouldn't have to restart that service.

If any of those services are running on your machine, then you have to stop all of them, then restart them in order for the changes to the configuration file be picked up.  Restarting the machine will also do the trick.

Comments (2)

  1. Thomas says:

    To verify, when starting the services back up, Net.TCP Port Sharing would be the first service, correct?

  2. JonCole says:

    The Net.Tcp Listener Adapter Service depends on the Net.Tcp Port Sharing Service.  Technically, the port sharing service has to be running before the Listener Adapter service.  However, since the Listener Adapter service knows of this dependency, starting the Listener Adapter should start the port sharing service automatically (although I have only verified this with the Services MMC).

Skip to main content