Servicehost throwing an error, even though added to configuration with netsh
Asked Answered
H

3

8

ServiceHost.Open() is throwing this error:

HTTP could not register URL http://+:8001/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

So I used netsh to add the url. But event though it is added, i'm still getting the error. This is the command I use:

netsh http add urlacl url=http://+:8001/ user=djerryy

djerryy is my computername. When I run netsh http show urlacl i see it was added.

What am I doing wrong?

Thanks in advance.

Headless answered 28/5, 2010 at 9:3 Comment(0)
G
23

It looks like you are missing the name of the user account who is running the service. Here's a couple of options:

  • Local user account:
netsh http add urlacl url=http://+:8001/ user=ComputerName\Username
  • Domain user account:
netsh http add urlacl url=http://+:8001/ user=DomainName\Username
  • Built-in NetworkService account:
netsh http add urlacl url=http://+:8001/ user="NT AUTHORITY\NETWORK SERVICE"
Guberniya answered 28/5, 2010 at 9:12 Comment(7)
i'm not in a domain. and i tried DJERRYY\Djerry, which still gave me the same errorHeadless
Where are you hosting your service? Do you start it from Visual Studio? What is the service endpoint?Guberniya
No, the service was installed with a setup project. It runs form windows services. This is the address i'm using as Uri : "net.tcp://localhost:8000", but i also tries adding 8000...Headless
That URL does not use HTTP as transport protocol. It uses TCP, so you shouldn't get that error. Shouldn't it be "localhost:8001" instead? Also, under which user account is the Windows Service running?Guberniya
you've lost me now: this (net.tcp://localhost:8000) isn't used in commands if i understand you correctly, it is the setup of my server (this link shows my setup : #2847597) the service is running as a network service, and i'm logged in as "djerry", which should be administrator.Headless
You need to grant access to the HTTP URL to the NetworkService account. I updated my answer with the correct command.Guberniya
at last, servicehost opened. Now to get my client connected again... :)Headless
T
5

I must stress:

netsh http add urlacl url=http://+:8001/ user="NT AUTHORITY\NETWORK SERVICE"

will work only on a system with the English locale!

A better way is to remove that one space and make it:

netsh http add urlacl url=http://+:8001/ user="NT AUTHORITY\NETWORKSERVICE"

Now the command will work on any locale. I spent a good 0,5h battling this today... all because of a single char. ;)

True answered 31/8, 2011 at 8:38 Comment(0)
S
0

To add even more to this answer: You MUST specify a port number! Spend quite a while trying to authorize a service to bind to a normal HTTP address, it only started working when I explicitly specified:

netsh http add urlacl 
    url=http://some.example.com:80/extension/ 
    user="NT AUTHORITY\NETWORKSERVICE"
Steger answered 8/5, 2013 at 13:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.