title: Selenium:Unexpected error. System.Net.WebException: Unable to connect to the remote server
body: <p>I have a web api application. Some method of the application runs chromedriver and makes some actions (sucs as clicks and taking screenshots)</p>
  
  <p>Under Visual Studio application works well.
  But when I publish my application to IIS, application throw Exception</p>
  
  <blockquote>
    <p>Unexpected error. System.Net.WebException: Unable to connect to the
    remote server ---> System.Net.Sockets.SocketException: No connection
    could be made because the target machine actively refused it
    127.0.0.1:51149 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at
    System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
    Socket s4, Socket s6, Socket&amp; socket, IPAddress&amp; address,
    ConnectSocketState state, IAsyncResult asyncResult, Exception&amp;
    exception)</p>
  </blockquote>
  
  <p>How to fix it?</p>
  
  <p>I saw familar questions on StackOverflow, but I didn't find an answer.</p>