title: .NET HttpListener: when registering both HTTP & HTTPS I get "conflicts with an existing registration on the machine"
body: <p>I'm trying to use .NET HttpListener in a C# project.  When I register my prefix "http://*:8080/" it does not seem to work for HTTPS urls (i.e. doesn't pick them up).  When I try the following code to register both the HTTP and HTTPS versions of the prefix however I get the error:</p>
  
  <p><strong><em>"Failed to listen on prefix 'https://</em>:8080/' because it conflicts with an existing registration on the machine."*</strong></p>
  
  <p>How can I get my prefix working for both HTTP &amp; HTTPS?</p>
  
  <pre><code>    private HttpListener _listener;
  
      // Create prefixes
      var prefixes = new List&lt;string&gt;();
      prefixes.Add("http://*:8080/");
      prefixes.Add("https://*:8080/");
  
  
      // Create HttpListener
      _listener = new HttpListener();
      foreach (string prefix in prefixes)
      {
          _listener.Prefixes.Add(prefix);
      }
  
      _listener.Start();   // &lt;== ERROR HERE
  </code></pre>
  
  <p>EDIT 1 - Additional clarification:</p>
  
  <ul>
  <li>The program is working as a local proxy for PC applications making HTTP(S) calls out.  </li>
  <li>Usage is therefore based on changing one's browser proxy settings to point to this local home grown proxy server (e.g. localhost:8080)</li>
  <li>This implies therefore (I assume) that the HttpListener has to listen for both HTTP and HTTPS traffic on this same local port (e.g. 8080).  </li>
  <li><strong>OBJECTIVE: Try to find a way for my program to listen to both HTTP and HTTPS on the same port</strong>.</li>
  </ul>
  
  <p>thanks</p>