TCP error code 10061: No connection could be made because the target machine actively refused it.

Answered TCP error code 10061: No connection could be made because the target machine actively refused it.

  • Friday, December 08, 2006 5:25 PM
     
     
    I hosted a wcf service application using windows services. When my client (ASP.NET) tries to call the service class hosted by the windows service, I get this error "TCP error code 10061: No connection could be made because the target machine actively refused it. ". Is there a fix for this? The same code works fine if I host it using a console application.

All Replies

  • Monday, December 11, 2006 4:16 PM
     
     Answered
    What port are you listening on? Is that port unblocked in your windows firewall?
  • Monday, December 11, 2006 6:11 PM
     
     
    Yes, my firewall was blocking it. I got around it and it fixed the problem.
  • Friday, April 06, 2007 12:45 PM
     
     
    which port ?
  • Friday, April 13, 2007 9:29 AM
     
     

    Hi,

     

    Evn i am gettin the same error. Can u tell me wat is the fix.

  • Monday, May 14, 2007 4:56 PM
     
     

    I am getting the same error - but only when I change my return type to a cutom object. CLR types work fine - i.e. an IList of Strings, but not, say, MyResponseObj. I'm running the asp.net development server on port 1212, with a wsHttpBinding. Like I said, the problem seems to be with the return type which is marked up with the DataContract - DataMember tags, like my other custom objects that work fine as input objects. I am able to pass in an arbitrarily complex object of custom types no problem - but the server tanks with a custom return type.

    Any suggestion would be appreciated. Thanx - Ian

  • Monday, May 14, 2007 5:15 PM
     
     

    Regarding the custom-return-types problem, if you configure tracing

    http://msdn2.microsoft.com/en-us/library/ms733025.aspx

    are there any exceptions on the server?

  • Monday, May 14, 2007 6:11 PM
     
     

    Brian

     

    I've configured trace in the web.config file as per the article, but no output or log file is generated. Do I need to create a trace object in my test code (NUnit) to explicitly start the trace segment?

    Or should the web.config entry be sufficient?

     

    Thanks,

    Ian

  • Friday, June 01, 2007 2:48 PM
     
     

    Kenny,

     

    I've unblocked the port on the firewall and still unable to connect.

    What was the fix?

  • Friday, June 01, 2007 4:49 PM
     
     
    For problem returning custom objects, turns out my IList<T> member variable, since it could be nullable, required this in the data contract: [DataMember(EmitDefaultValue = false)]
    That is what was causing the service to refuse the connection. Now all is well again.  A newbie error no doubt, but I never even heard of WCF before I started at my new company.  =o)
  • Saturday, June 02, 2007 8:10 PM
     
     
    What port are you using? What binding is this? Can you connect to the port using IE (assuming you have an HTTP GET metadata enabled)?
  • Wednesday, August 22, 2007 6:28 AM
     
     

    Hi ,

     

    I am getting this error if I host it using a console application. it works fine if client is asp.net. Is there a fix for this?

     

    -ravi

  • Friday, August 01, 2008 8:45 PM
     
     

    try to remove and add service refrences again...it will help you to connect wcf...

  • Wednesday, August 13, 2008 2:45 PM
     
     

    Hi JothiMurugan,

     

    I am also getting same error when I host with the windows service.

    Same application when hosted in Console application, works fine.

    Can you please help me with the fix.

     

    Thanks in advance.

    Sakthi

  • Thursday, August 21, 2008 12:19 PM
     
     
    hi
    i don't know it will helpfull to u or not but u should try it
    first u click on  host  project and  click on Start new instance
    then u should run windows application
  • Friday, August 07, 2009 6:41 PM
     
     
    I have configured Tracing and I see my trace files just fine, the prblem is I don't see an Error icon. 

    I'm looking through all the activities in the trace viewer and the one for my service operation has To and from transport messages, I can see the start for the activity but there is nothing indicating an error and I setup it up for  switchValue="Error,ActivityTracing". 

    ??

    Santiago Perez
  • Thursday, August 27, 2009 2:37 AM
     
     
    Hi,
    I am trying to write a WCF service with transport level security and basicHTTP binding. I am using a custom Membership provider to authenticate a client call to the service by authenticating the User ID and password passed to the service. I believe that WCF does not allow UserID/Password auth without having SSL certificate installed because the UserID/password are sent as clear text. I am currently in development and I tried installing the test certificate (X.509) on my dev machine running the service but w/o any success.
    My service web.config looks like this

    <

     

    system.serviceModel>

    <

     

    services>

    <

     

    service behaviorConfiguration="LCCService.rbagLCWS_ServiceBehavior"

     

     

    name="LCCService.rbagLCWS_Service">

    <

     

    endpoint address=""

     

     

    binding="basicHttpBinding"

     

     

    bindingConfiguration="LCCService.rbagLCWS_ServiceBinding"

     

     

    contract="LCCService.IrbagLCWS_service">

    </

     

    endpoint>

    <

     

    endpoint address="mex"

     

     

    binding="mexHttpBinding"

     

     

    contract="IMetadataExchange" />

    </

     

    service>

    </

     

    services>

    <

     

    behaviors>

    <

     

    serviceBehaviors>

    <

     

    behavior name="LCCService.rbagLCWS_ServiceBehavior">

    <

     

    serviceCredentials>

    <

     

    userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="PasswordProvider"/>

    </

     

    serviceCredentials>

    <

     

    serviceMetadata httpGetEnabled="true" />

    <

     

    serviceDebug includeExceptionDetailInFaults="true" />

    </

     

    behavior>

    </

     

    serviceBehaviors>

    </

     

    behaviors>

    <

     

    bindings>

    <

     

    basicHttpBinding>

    <

     

    binding name="LCCService.rbagLCWS_ServiceBinding">

    <

     

    security mode="Transport">

    <

     

    transport clientCredentialType="Basic"/>

    </

     

    security>

    </

     

    binding>

    </

     

    basicHttpBinding>

    </

     

    bindings>

    </

     

    system.serviceModel>


    When I try to call the service using the client w/o having the test certification installed, I get the following error:
    Could not connect to https://XYZ.com/rrxainet/LCCWCFService/rbagLCWS_service.svc. TCP error code 10061: No connection could be made because the target machine actively refused it XXX.XXX.XX.XXX:443.

    I have spent almost 2 days trying to figure out the solution and how to successfully install the test certificate to get it working but to no avail.

    Please can someone help. I really appreciate it!!!

  • Friday, January 15, 2010 7:27 AM
     
     
    hi guys,

    i am new to dot net. when i am using the folling program for connecting the particuler port it is giving the error.

    int

     

    timout = Convert.ToInt32(txttimeout.Text);

     

    int port = 5000;

     

    IPAddress localAddr = IPAddress.Parse("127.0.0.1");

     

    IPEndPoint remoteEndPoint = new IPEndPoint(localAddr, port);

     

     

    TcpClient NetworkClient = TimeOutSocket.Connect(remoteEndPoint, timout);

     

    NetworkStream networkstream = NetworkClient.GetStream();

     

    StreamReader streamReader = new StreamReader(networkstream);

     

    string line = streamReader.ReadToEnd(); //streamReader.ReadLine();

  • Tuesday, March 16, 2010 4:25 AM
     
     
    I got the same message after adding the registry value  "KeepAliveTime" with value 300000 in the window registry under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters.

    When I removed the window registry "KeepAliveTime", it resumed normal.

    Is there any settings I have to check ?
  • Friday, July 09, 2010 11:38 AM
     
     

    Hi All,

     I am new to WCF. I have created a WCF Service and hosted it in Windows Service. I have got a below Error when tring to create Client Proxy for the service.

    Error Message:

    "There was an error downloading 'http://localhost:8051/Service1/'.
    Unable to connect to the remote server
    No connection could be made because the target machine actively refused it 127.0.0.1:8051
    Metadata contains a reference that cannot be resolved: 'http://localhost:8051/Service1/'.
    Could not connect to http://localhost:8051/Service1/. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8051.
    Unable to connect to the remote server
    No connection could be made because the target machine actively refused it 127.0.0.1:8051
    If the service is defined in the current solution, try building the solution and adding the service reference again."

    I have seen some posts related to Issue like unblocking the port in Firewall. I have unblocked all ports from Firewall, Still the Issue raising while create Client Proxy. Some one can help me on this Problem. I have Pasted my configuration file below.

    <system.serviceModel>
        <services>
          <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
            <!-- Service Endpoints -->
            <endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1">
            </endpoint>
            <!--<endpoint address="" binding="netTcpBinding" contract="WcfService1.IService1"></endpoint>-->
            <!--<endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>-->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8051/Service1/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WcfService1.Service1Behavior">
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

     

    Please reply me to solve this problem.

     

  • Monday, August 02, 2010 8:17 PM
     
     

    I started getting this problem in VS 2008 IDE when I'm testing my web services.  Not a firewall issue.  Anyone find a positive solution to this??

    My Web Service test web application used to work fine a few months ago -- now when I test it I get this error?  So I'm guessing some OS update has broken VS 2008 IDE for web services??

    Rob

  • Monday, August 02, 2010 10:23 PM
     
     Proposed Answer

    Solved the problem for my case (appears to a Project's Web Service reference issue):

    In VS 2008 IDE

    In your actual Web Services Project (with the ASMX source) - My Project | Web | Use Visual Studio Development Server | Auto-assign Port.

    a. If this is hard coded to a specific port you'll need to verify the calling Project's Web Service references match the same port and reference.

    b. Open your calling project - My Project | References - remove your Web Service references (Type = Service) - be sure to note the ReferenceName you used.  Now Add Service Reference back again - Discover Services in Solution, select the service and be sure to re-enter the same ReferenceName you used originally.

    If your Web Service project is configured differently or you reference external web services, then it might just be a case of removing and re-adding the web service back being sure to use the same ReferenceName so you project references stay intact.

    Rob.

     

    • Proposed As Answer by Rob Ainscough Monday, August 02, 2010 10:23 PM
    •  
  • Monday, September 27, 2010 10:11 AM
     
      Has Code
    Hi I'm new to WCF.. I'm trying to invoke free web service
    

    http://www.mindreef.net/svc/hashservice/servicesHashClassSoap?wsdl....

    So i have created a client but it gives me an exception..Please help me


    Could not connect to http://localhost:8050/hashservice/services/HashClassSoap.
    
    
    TCP error code 10061: No connection could be made because the target machine 
    
    
    actively refused it 127.0.0.1:8050. 
    
    Server stack trace: 
     at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
     at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
     at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.
    
    
    HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
     at System.ServiceModel.Channels.RequestChannel.Request(Message message,
    
    
     TimeSpan timeout)
     at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message,
    
    
     TimeSpan timeout)
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean 
    
    
    oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan
    
    
     timeout)
     at System.ServiceModel.Channels.ServiceChannel.Call(String action,
    
    
     Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
     at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(
    
    
    IMethodCallMessage methodCall, ProxyOperationRuntime operation)
     at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    
    Exception rethrown at [0]: 
     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,
    
    
     IMessage retMsg)
     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,
    
    
     Int32 type)
     at HashClassSoap.CheckHash(CheckHashRequest request)
     at HashClassSoapClient.HashClassSoap.CheckHash(CheckHashRequest request)
    
    
    
    

  • Saturday, November 13, 2010 11:34 AM
     
     
    you have added your wcf reference by selecting wcf project node. to resolve it select your test project node and add wcf reference. i hope it will work.
  • Saturday, November 13, 2010 11:34 AM
     
     
    you have added your wcf reference by selecting wcf project node. to resolve it select your test project node and add wcf reference. i hope it will work.
  • Friday, December 17, 2010 9:17 PM
     
     
    Yeah! First time I ever fixed ANYTHING! Error went away when changed properties of project to use IIS instead of local directory.  Set the project to use IIS, click the button to create a virtual directory and...c'est voila!.  Good luck.
  • Tuesday, December 21, 2010 8:05 PM
     
     
    TrollSpouse, I seem to have this problem, but I don't understand the solution you found. Could you be more specific where in properties you configured  to use IIS instead of local directory? Thanks.
  • Monday, June 13, 2011 9:53 PM
     
     
    Make sure that "Net.Tcp Listener" is running go to  ControlPanel/Administrative Tools/Services
    also "Net.Tcp Port Sharing"  Service.
  • Friday, March 09, 2012 3:07 PM
     
     

    My Net.tcp listener shows as starting, however starts... it shows the net.tcp Port Sharing as started, as well as the Windows Process Activation Service as started... i get the 10061 error as well... any idea how I can fix this?  would a service admin logon do it versus Local System/Service?