Search code examples
httpshttplistener

Https listener .NET failed on port 443


I am developing a http listener to access a remote process. Example code snippet:

HttpListener listener = new HttpListener();
listener.Prefixes.Add("https://*:443/");
listener.Start();
Console.WriteLine("Listening...");
for (; ; )
{
HttpListenerContext ctx = listener.GetContext();
new Thread(new Worker(ctx).ProcessRequest).Start();
}

This is working as expected if I use port 8080, but fails on port 443. The exception is

System.Net.HttpListenerException was unhandled
Message=The process cannot access the file because it is being used by another process

Solution

  • Please ensure that is there any other web sites (in IIS or Apache) serving through the port 443 with SSL? It should be the common cause for the reported issue.

    You may try some other port to see if the same exception is thrown by HttpListener object.