No connection could be made because the target machine actively refused it


  • Hi I am trying to send a mail from my application and am getting the following error


    Exception Type:        System.Net.Sockets.SocketException
    Exception Message:     No connection could be made because the target machine actively refused it
    Exception Source:      System
    Exception Target Site: Connect

    ---- Stack Trace ----
       System.Net.Sockets.Socket.Connect(remoteEP As EndPoint)
           (unknown file): N 00309
       BossWare.Mail.SmtpTcpClient.Connect(hostName As String, port As Int32)
           (unknown file): N 00101
       BossWare.Mail.SmtpClientConnection.Connect(connectionArgs As IConnectionArgs)
           (unknown file): N 00255


    Any help will be great 


    Tuesday, September 12, 2006 12:16 PM


  • means no body is listening on that port on that machine
    Tuesday, September 12, 2006 1:57 PM

All replies

  • means no body is listening on that port on that machine
    Tuesday, September 12, 2006 1:57 PM
  • Dear Durgaprasad Gorti

             I am facing sam eproblem. I dont know much idea about this. So plz replay me

    How I set the port for listening on my machine

                             Advance thanks



    Thursday, September 28, 2006 7:17 AM
  • You get this error when your try to connect to a computer on a specific port and the host computer is not listening for any request on that port.


    Computer 'B' tries to connect Computer 'A' at port 8043 while Computer 'A' is running no service which is listening to accept incoming connection request at port 8043.

    For two computer to establish a connection both must agree upon using the same port of connections.

    I hope this will help you.

    Best Regards,

    Thursday, September 28, 2006 7:58 AM
  • I have the same issue when I am trying to call a method on a remote object. I checked if the port is in listening mode or not using the "net stat" and I see that the post is listening. I dont understand why I still get the exception!! Any ideas?
    Sunday, October 22, 2006 10:54 PM
  • even I have the same issue , I am using ASPNETDEVELOPMENTSERVER to host my custom handler, after running the Test method , it hosts my handler for a while, and in the middle terminates ,which causes the error in my test method later.

    does anyone has any idea , why this is happening.

    Another interesting fact is , when I debug my test method , it works properly , no issues. but when I run it results in net socket exception .... cant connect to the port because the target machine actively refused it...

    Any one has any idea on this , why is it hapening ???

    Friday, September 05, 2008 4:50 AM
  • I also faced this same issue while making client server chat app.

    Its because I have written only client interface, so there was not server. and my app was trying to connect. if there is no server, then it will throw the above exception. so I think your smtp configuration might be wrong, check it. and firewall setting also.


    Thank you

    Sachin Patil

    Software engineer|Fast Track Software Services Pvt Ltd

    K6/3 Erandwane Pune 411004 India

    m: 91.902.125.3556|www.fasttrackteam.com|



    Thursday, December 30, 2010 9:49 AM
  • Hey,

    Try Follow the steps

    1. Select the site or Virtual Directory in IIS

    2. In Feature View, Right side you see SMTP mail

    3. if exists, Click to open a dialogbox

    4. Goto Radio button "Store e-mail in pickup directory" enter a valid directory path,

    5. Your SMTP starts working, it will not send mails, but all outgoing
    mail formats you can see, this would be great while debugging,
    insteading of choking your mail server.


    Hope it helps,



    Thursday, September 06, 2012 12:22 PM
  • Guys!,

    Better technical crowd available at


    ( everybody elaborating the question  and networking fundamentals here :), please give a workable solution techies)


    Thursday, September 06, 2012 12:25 PM