Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service cannot be started. Could not register URL

I want to host wcf in window service. I've done several times before without any problem. This time After I installed the service and click on start I get the following error in EventViewer.

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

When I host the same service, same address on ConsoleApplication - all right.

I saw the questions here and here, but none of the solutions helped me.

Does anyone have an idea?

like image 989
Harry Avatar asked Dec 16 '12 13:12

Harry


2 Answers

As for your answer, that's a bit of shotgun debugging. You now have a network service with administrator privileges:

LocalSystem Account (Windows):

The LocalSystem account [...] has extensive privileges on the local computer, and acts as the computer on the network. Its token includes the NT AUTHORITY\SYSTEM and BUILTIN\Administrators SIDs; these accounts have access to most system objects.

Most services do not need such a high privilege level. If your service does not need these privileges, and it is not an interactive service, consider using the LocalService account or the NetworkService account. For more information, see Service Security and Access Rights.

So you'd better run this service as NetworkService, and give it the proper permissions to use the port you're trying to use as explained in Configuring HTTP and HTTPS:

netsh http add urlacl url=http://+:80/MyUri user="NT AUTHORITY\NETWORK SERVICE"
like image 164
CodeCaster Avatar answered Nov 10 '22 16:11

CodeCaster


I found that changing installer account to LocalSystem did the job :-)

like image 22
Harry Avatar answered Nov 10 '22 16:11

Harry