Why do I get WCF Exception “HTTP could not register URL http://+:80/MyService/”

I create my host with the endpointaddress it needs to use, like this:

Uri endpointAddress = new Uri("");
ServiceHost host = new ServiceHost(myServiceType, endpointAddress);
host.AddServiceEndpoint(implementedContract, basicHttpBinding, string.Empty);

but when I later do host.Open(); I get the exception "HTTP could not register URL http://+:80/MyService/ because TCP port 80 is being used by another application". The result is the same when I do

host.AddServiceEndpoint(implementedContract, basicHttpBinding, endpointAddress);

Why would it try to do anything with port 80? How can I solve this?

Update While trying to provide a more complete code sample, I found the culprit. I added a ServiceMetadataBehavior as follows:

ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.ExternalMetadataLocation = new Uri(this.ExternalMetadataLocation);
smb.HttpGetEnabled = true;
smb.HttpGetUrl = this.RemovePort(this.EndpointAddress);

It seems that in the past I needed to remove the port from the URL to get this to work, but now that's exactly what causes the problem.

So Pratik is right: metadata were the problem, and of course the problem with port 80 is that there's some newly installed application using that port.

Thanks, regards,



This is because port 80 is already used by another applicatiion as the error message says, most likely by local IIS server. Try stopping IIS and see, or use another port. On vista and above you can use netsh command to check which ports are already reserved

BTW do you have http metadata or mex endpoints in the app.config or web.config file ?

The following works fine for me:

class Program
    public interface IMyService
        void Test();

    public class MyService : IMyService
        public void Test()
            throw new NotImplementedException();

    static void Main()
        var endpointAddress = new Uri("");
        using (var host = new ServiceHost(typeof(MyService), endpointAddress))
            var basicHttpBinding = new BasicHttpBinding();
            host.AddServiceEndpoint(typeof(IMyService), basicHttpBinding, string.Empty);

Maybe you have some other code which is interfering?

Need Your Help

Where do app images get stored in Rails 3.1?


With the introduction of the new directory structure in 3.1 (i.e. app/assets/), should app images (logo, banner, icons, main bg, etc) still be stored in public/images or should they go into

Is there an iOS API for ‘With Friends’ game?

iphone ios gamekit social

I want to build a simple iOS game that players can play with their friends (something similar to Draw Something). Is there some kind of API for matchmaking? I’ve taken a look at GameCenter and the ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.